@adhisang/minecraft-modding-mcp 3.2.0 → 4.1.0

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 (194) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +52 -32
  3. package/dist/build-suggested-call.d.ts +29 -0
  4. package/dist/build-suggested-call.js +58 -0
  5. package/dist/cache-registry.d.ts +3 -1
  6. package/dist/cache-registry.js +59 -7
  7. package/dist/config.d.ts +10 -1
  8. package/dist/config.js +52 -1
  9. package/dist/entry-tools/analyze-symbol-service.d.ts +18 -18
  10. package/dist/entry-tools/analyze-symbol-service.js +13 -2
  11. package/dist/entry-tools/batch-class-members-service.d.ts +34 -0
  12. package/dist/entry-tools/batch-class-members-service.js +97 -0
  13. package/dist/entry-tools/batch-class-source-service.d.ts +37 -0
  14. package/dist/entry-tools/batch-class-source-service.js +100 -0
  15. package/dist/entry-tools/batch-mappings-service.d.ts +36 -0
  16. package/dist/entry-tools/batch-mappings-service.js +66 -0
  17. package/dist/entry-tools/batch-runner.d.ts +72 -0
  18. package/dist/entry-tools/batch-runner.js +90 -0
  19. package/dist/entry-tools/batch-symbol-exists-service.d.ts +46 -0
  20. package/dist/entry-tools/batch-symbol-exists-service.js +113 -0
  21. package/dist/entry-tools/compare-minecraft-service.d.ts +6 -6
  22. package/dist/entry-tools/inspect-minecraft/handlers/artifact.d.ts +5 -0
  23. package/dist/entry-tools/inspect-minecraft/handlers/artifact.js +83 -0
  24. package/dist/entry-tools/inspect-minecraft/handlers/class-members.d.ts +6 -0
  25. package/dist/entry-tools/inspect-minecraft/handlers/class-members.js +80 -0
  26. package/dist/entry-tools/inspect-minecraft/handlers/class-overview.d.ts +5 -0
  27. package/dist/entry-tools/inspect-minecraft/handlers/class-overview.js +248 -0
  28. package/dist/entry-tools/inspect-minecraft/handlers/class-source.d.ts +5 -0
  29. package/dist/entry-tools/inspect-minecraft/handlers/class-source.js +60 -0
  30. package/dist/entry-tools/inspect-minecraft/handlers/file.d.ts +5 -0
  31. package/dist/entry-tools/inspect-minecraft/handlers/file.js +54 -0
  32. package/dist/entry-tools/inspect-minecraft/handlers/list-files.d.ts +5 -0
  33. package/dist/entry-tools/inspect-minecraft/handlers/list-files.js +100 -0
  34. package/dist/entry-tools/inspect-minecraft/handlers/search.d.ts +5 -0
  35. package/dist/entry-tools/inspect-minecraft/handlers/search.js +155 -0
  36. package/dist/entry-tools/inspect-minecraft/handlers/versions.d.ts +6 -0
  37. package/dist/entry-tools/inspect-minecraft/handlers/versions.js +49 -0
  38. package/dist/entry-tools/inspect-minecraft/internal.d.ts +1042 -0
  39. package/dist/entry-tools/inspect-minecraft/internal.js +448 -0
  40. package/dist/entry-tools/inspect-minecraft-service.d.ts +213 -328
  41. package/dist/entry-tools/inspect-minecraft-service.js +20 -1238
  42. package/dist/entry-tools/manage-cache-service.d.ts +16 -16
  43. package/dist/entry-tools/validate-project/cases/access-transformer.d.ts +6 -0
  44. package/dist/entry-tools/validate-project/cases/access-transformer.js +106 -0
  45. package/dist/entry-tools/validate-project/cases/access-widener.d.ts +6 -0
  46. package/dist/entry-tools/validate-project/cases/access-widener.js +86 -0
  47. package/dist/entry-tools/validate-project/cases/mixin.d.ts +6 -0
  48. package/dist/entry-tools/validate-project/cases/mixin.js +90 -0
  49. package/dist/entry-tools/validate-project/cases/project-summary.d.ts +97 -0
  50. package/dist/entry-tools/validate-project/cases/project-summary.js +346 -0
  51. package/dist/entry-tools/validate-project/internal.d.ts +135 -0
  52. package/dist/entry-tools/validate-project/internal.js +287 -0
  53. package/dist/entry-tools/validate-project-service.d.ts +63 -47
  54. package/dist/entry-tools/validate-project-service.js +12 -482
  55. package/dist/entry-tools/verify-mixin-target-service.d.ts +133 -0
  56. package/dist/entry-tools/verify-mixin-target-service.js +323 -0
  57. package/dist/error-mapping.d.ts +40 -0
  58. package/dist/error-mapping.js +139 -0
  59. package/dist/errors.d.ts +6 -0
  60. package/dist/errors.js +6 -0
  61. package/dist/index.d.ts +2 -0
  62. package/dist/index.js +170 -1314
  63. package/dist/lru-list.d.ts +31 -0
  64. package/dist/lru-list.js +102 -0
  65. package/dist/mapping/internal-types.d.ts +54 -0
  66. package/dist/mapping/internal-types.js +14 -0
  67. package/dist/mapping/loaders/mojang.d.ts +2 -0
  68. package/dist/mapping/loaders/mojang.js +64 -0
  69. package/dist/mapping/loaders/tiny-loom.d.ts +2 -0
  70. package/dist/mapping/loaders/tiny-loom.js +73 -0
  71. package/dist/mapping/loaders/tiny-maven.d.ts +2 -0
  72. package/dist/mapping/loaders/tiny-maven.js +104 -0
  73. package/dist/mapping/loaders/types.d.ts +14 -0
  74. package/dist/mapping/loaders/types.js +2 -0
  75. package/dist/mapping/lookup.d.ts +52 -0
  76. package/dist/mapping/lookup.js +496 -0
  77. package/dist/mapping/parsers/normalize.d.ts +10 -0
  78. package/dist/mapping/parsers/normalize.js +52 -0
  79. package/dist/mapping/parsers/proguard.d.ts +20 -0
  80. package/dist/mapping/parsers/proguard.js +138 -0
  81. package/dist/mapping/parsers/symbol-records.d.ts +27 -0
  82. package/dist/mapping/parsers/symbol-records.js +216 -0
  83. package/dist/mapping/parsers/tiny.d.ts +9 -0
  84. package/dist/mapping/parsers/tiny.js +96 -0
  85. package/dist/mapping/types.d.ts +147 -0
  86. package/dist/mapping/types.js +2 -0
  87. package/dist/mapping-pipeline-service.d.ts +10 -1
  88. package/dist/mapping-pipeline-service.js +16 -3
  89. package/dist/mapping-service.d.ts +15 -144
  90. package/dist/mapping-service.js +179 -1119
  91. package/dist/mixin/access-validators.d.ts +9 -0
  92. package/dist/mixin/access-validators.js +257 -0
  93. package/dist/mixin/annotation-validators.d.ts +5 -0
  94. package/dist/mixin/annotation-validators.js +162 -0
  95. package/dist/mixin/helpers.d.ts +28 -0
  96. package/dist/mixin/helpers.js +315 -0
  97. package/dist/mixin/parsed-validator.d.ts +8 -0
  98. package/dist/mixin/parsed-validator.js +337 -0
  99. package/dist/mixin/types.d.ts +208 -0
  100. package/dist/mixin/types.js +28 -0
  101. package/dist/mixin-validator.d.ts +9 -201
  102. package/dist/mixin-validator.js +8 -1005
  103. package/dist/observability.d.ts +18 -1
  104. package/dist/observability.js +44 -1
  105. package/dist/response-utils.d.ts +44 -10
  106. package/dist/response-utils.js +131 -17
  107. package/dist/source/access-validate.d.ts +4 -0
  108. package/dist/source/access-validate.js +254 -0
  109. package/dist/source/artifact-resolver.d.ts +110 -0
  110. package/dist/source/artifact-resolver.js +1174 -0
  111. package/dist/source/cache-metrics.d.ts +26 -0
  112. package/dist/source/cache-metrics.js +172 -0
  113. package/dist/source/class-source/members-builder.d.ts +34 -0
  114. package/dist/source/class-source/members-builder.js +46 -0
  115. package/dist/source/class-source/snippet-builder.d.ts +19 -0
  116. package/dist/source/class-source/snippet-builder.js +46 -0
  117. package/dist/source/class-source-helpers.d.ts +34 -0
  118. package/dist/source/class-source-helpers.js +140 -0
  119. package/dist/source/class-source.d.ts +42 -0
  120. package/dist/source/class-source.js +883 -0
  121. package/dist/source/descriptor-utils.d.ts +6 -0
  122. package/dist/source/descriptor-utils.js +37 -0
  123. package/dist/source/file-access.d.ts +4 -0
  124. package/dist/source/file-access.js +102 -0
  125. package/dist/source/indexer.d.ts +82 -0
  126. package/dist/source/indexer.js +505 -0
  127. package/dist/source/lifecycle/diff-utils.d.ts +9 -0
  128. package/dist/source/lifecycle/diff-utils.js +107 -0
  129. package/dist/source/lifecycle/diff.d.ts +2 -0
  130. package/dist/source/lifecycle/diff.js +265 -0
  131. package/dist/source/lifecycle/mapping-helpers.d.ts +22 -0
  132. package/dist/source/lifecycle/mapping-helpers.js +327 -0
  133. package/dist/source/lifecycle/runtime-check.d.ts +2 -0
  134. package/dist/source/lifecycle/runtime-check.js +142 -0
  135. package/dist/source/lifecycle/trace.d.ts +2 -0
  136. package/dist/source/lifecycle/trace.js +231 -0
  137. package/dist/source/lifecycle.d.ts +4 -0
  138. package/dist/source/lifecycle.js +5 -0
  139. package/dist/source/search.d.ts +51 -0
  140. package/dist/source/search.js +676 -0
  141. package/dist/source/shared-utils.d.ts +6 -0
  142. package/dist/source/shared-utils.js +55 -0
  143. package/dist/source/state.d.ts +21 -0
  144. package/dist/source/state.js +19 -0
  145. package/dist/source/symbol-resolver.d.ts +3 -0
  146. package/dist/source/symbol-resolver.js +212 -0
  147. package/dist/source/validate-mixin/pipeline/mapping-health.d.ts +3 -0
  148. package/dist/source/validate-mixin/pipeline/mapping-health.js +41 -0
  149. package/dist/source/validate-mixin/pipeline/parse.d.ts +2 -0
  150. package/dist/source/validate-mixin/pipeline/parse.js +10 -0
  151. package/dist/source/validate-mixin/pipeline/resolve.d.ts +3 -0
  152. package/dist/source/validate-mixin/pipeline/resolve.js +78 -0
  153. package/dist/source/validate-mixin/pipeline/target-lookup.d.ts +6 -0
  154. package/dist/source/validate-mixin/pipeline/target-lookup.js +260 -0
  155. package/dist/source/validate-mixin/pipeline-context.d.ts +72 -0
  156. package/dist/source/validate-mixin/pipeline-context.js +93 -0
  157. package/dist/source/validate-mixin.d.ts +22 -0
  158. package/dist/source/validate-mixin.js +799 -0
  159. package/dist/source/workspace-target.d.ts +18 -0
  160. package/dist/source/workspace-target.js +305 -0
  161. package/dist/source-resolver.d.ts +9 -1
  162. package/dist/source-resolver.js +14 -6
  163. package/dist/source-service.d.ts +178 -105
  164. package/dist/source-service.js +72 -5312
  165. package/dist/stage-emitter.d.ts +13 -0
  166. package/dist/stage-emitter.js +30 -0
  167. package/dist/stdio-supervisor.d.ts +61 -0
  168. package/dist/stdio-supervisor.js +326 -9
  169. package/dist/storage/artifacts-repo.d.ts +4 -1
  170. package/dist/storage/artifacts-repo.js +33 -5
  171. package/dist/storage/files-repo.d.ts +0 -2
  172. package/dist/storage/files-repo.js +0 -11
  173. package/dist/storage/migrations.d.ts +1 -1
  174. package/dist/storage/migrations.js +10 -2
  175. package/dist/storage/schema.d.ts +2 -0
  176. package/dist/storage/schema.js +25 -0
  177. package/dist/tool-contract-manifest.d.ts +1 -1
  178. package/dist/tool-contract-manifest.js +23 -6
  179. package/dist/tool-guidance.d.ts +82 -0
  180. package/dist/tool-guidance.js +734 -0
  181. package/dist/tool-schema-registry.d.ts +16 -0
  182. package/dist/tool-schema-registry.js +37 -0
  183. package/dist/tool-schemas.d.ts +3518 -0
  184. package/dist/tool-schemas.js +813 -0
  185. package/dist/types.d.ts +39 -0
  186. package/dist/version-service.js +7 -6
  187. package/dist/workspace-context-cache.d.ts +32 -0
  188. package/dist/workspace-context-cache.js +66 -0
  189. package/dist/workspace-mapping-service.d.ts +16 -0
  190. package/dist/workspace-mapping-service.js +173 -1
  191. package/docs/README-ja.md +414 -0
  192. package/docs/examples.md +483 -0
  193. package/docs/tool-reference.md +459 -0
  194. package/package.json +5 -2
@@ -1,1008 +1,11 @@
1
1
  /**
2
- * Validation engine for parsed Mixin sources and Access Widener files.
3
- * Compares parsed annotations against resolved Minecraft bytecode signatures.
2
+ * Public barrel for the mixin validation engine. The implementation lives
3
+ * under `src/mixin/`; this file preserves the historical entry point used
4
+ * by source-service, entry tools, and tests.
4
5
  */
5
- const TOOL_RESOLUTION_PATHS = [
6
- "target-mapping-failed",
7
- "member-remap-failed",
8
- "source-signature-unavailable"
9
- ];
10
- const MAPPING_WARNING_RE = /(?:mapping|remap|fallback|could not map)/i;
11
- const CONFIG_WARNING_RE = /(?:version|gradle|jar\b|properties|project)/i;
12
- const PARSE_WARNING_RE = /(?:could not parse|parse\s+warning|missing method attribute)/i;
13
- function classifyStructuredWarning(message) {
14
- return {
15
- severity: MAPPING_WARNING_RE.test(message) ? "warning" : PARSE_WARNING_RE.test(message) ? "warning" : "info",
16
- message,
17
- category: MAPPING_WARNING_RE.test(message)
18
- ? "mapping"
19
- : PARSE_WARNING_RE.test(message)
20
- ? "parse"
21
- : CONFIG_WARNING_RE.test(message)
22
- ? "configuration"
23
- : "validation"
24
- };
25
- }
26
- /* ------------------------------------------------------------------ */
27
- /* Levenshtein distance */
28
- /* ------------------------------------------------------------------ */
29
- export function levenshteinDistance(a, b) {
30
- const la = a.length;
31
- const lb = b.length;
32
- if (la === 0)
33
- return lb;
34
- if (lb === 0)
35
- return la;
36
- // Single-row DP
37
- const prev = new Array(lb + 1);
38
- for (let j = 0; j <= lb; j++)
39
- prev[j] = j;
40
- for (let i = 1; i <= la; i++) {
41
- let diagPrev = prev[0];
42
- prev[0] = i;
43
- for (let j = 1; j <= lb; j++) {
44
- const temp = prev[j];
45
- if (a[i - 1] === b[j - 1]) {
46
- prev[j] = diagPrev;
47
- }
48
- else {
49
- prev[j] = 1 + Math.min(diagPrev, prev[j - 1], prev[j]);
50
- }
51
- diagPrev = temp;
52
- }
53
- }
54
- return prev[lb];
55
- }
56
- export function suggestSimilar(name, candidates, maxDistance = 3, maxResults = 3) {
57
- const normalizedName = name.toLowerCase();
58
- const scored = [];
59
- for (const candidate of candidates) {
60
- const normalizedCandidate = candidate.toLowerCase();
61
- if (Math.abs(normalizedName.length - normalizedCandidate.length) > maxDistance) {
62
- continue;
63
- }
64
- const distance = levenshteinDistance(normalizedName, normalizedCandidate);
65
- if (distance <= maxDistance && distance > 0) {
66
- scored.push({ candidate, distance });
67
- }
68
- }
69
- scored.sort((a, b) => a.distance - b.distance);
70
- return scored.slice(0, maxResults).map((s) => s.candidate);
71
- }
72
- /* ------------------------------------------------------------------ */
73
- /* Method reference helpers */
74
- /* ------------------------------------------------------------------ */
75
- /**
76
- * Strip owner prefix (`Lowner;`) and JVM descriptor (`(...)V`) from a
77
- * Mixin method reference, returning just the method name.
78
- *
79
- * Examples:
80
- * "playerTouch(Lnet/minecraft/world/entity/player/Player;)V" → "playerTouch"
81
- * "Lnet/minecraft/SomeClass;tick(I)V" → "tick"
82
- * "<init>" → "<init>"
83
- * "<init>()V" → "<init>"
84
- * "tick" → "tick"
85
- */
86
- function stripOwnerPrefix(ref) {
87
- if (!ref.startsWith("L"))
88
- return ref;
89
- const ownerEnd = ref.indexOf(";");
90
- if (ownerEnd === -1)
91
- return ref;
92
- const parenIdx = ref.indexOf("(");
93
- // Owner prefixes appear before the descriptor, e.g. Lpkg/Class;method(I)V.
94
- // If ';' appears inside the descriptor, this is not an owner prefix.
95
- if (parenIdx !== -1 && ownerEnd > parenIdx)
96
- return ref;
97
- return ref.substring(ownerEnd + 1);
98
- }
99
- export function extractMethodName(ref) {
100
- let s = stripOwnerPrefix(ref);
101
- // Remove descriptor: everything from '(' onwards
102
- const parenIdx = s.indexOf("(");
103
- if (parenIdx !== -1) {
104
- s = s.substring(0, parenIdx);
105
- }
106
- return s;
107
- }
108
- /**
109
- * Extract the JVM descriptor portion from a method reference, if present.
110
- *
111
- * Examples:
112
- * "playerTouch(Lnet/minecraft/world/entity/player/Player;)V" → "(Lnet/minecraft/world/entity/player/Player;)V"
113
- * "tick" → undefined
114
- */
115
- export function extractMethodDescriptor(ref) {
116
- // After stripping optional owner prefix, find '('
117
- const s = stripOwnerPrefix(ref);
118
- const parenIdx = s.indexOf("(");
119
- if (parenIdx !== -1) {
120
- return s.substring(parenIdx);
121
- }
122
- return undefined;
123
- }
124
- /* ------------------------------------------------------------------ */
125
- /* Mixin validation */
126
- /* ------------------------------------------------------------------ */
127
- function allMethodNames(members) {
128
- return [
129
- ...members.constructors.map((m) => m.name),
130
- ...members.methods.map((m) => m.name)
131
- ];
132
- }
133
- function allFieldNames(members) {
134
- return members.fields.map((m) => m.name);
135
- }
136
- function accessLevelFromFlags(accessFlags) {
137
- if (accessFlags == null) {
138
- return undefined;
139
- }
140
- if ((accessFlags & 0x0001) !== 0) {
141
- return "public";
142
- }
143
- if ((accessFlags & 0x0004) !== 0) {
144
- return "protected";
145
- }
146
- if ((accessFlags & 0x0002) !== 0) {
147
- return "private";
148
- }
149
- return "package-private";
150
- }
151
- function computeFalsePositiveRisk(healthReport, resolutionPath, issueConfidence) {
152
- if (!healthReport)
153
- return undefined;
154
- if (healthReport.overallHealthy === false) {
155
- if (resolutionPath === "source-signature-unavailable" ||
156
- resolutionPath === "target-mapping-failed" ||
157
- resolutionPath === "member-remap-failed")
158
- return "high";
159
- if (issueConfidence === "uncertain")
160
- return "medium";
161
- return "medium";
162
- }
163
- if (healthReport.memberRemapAvailable === false) {
164
- if (resolutionPath === "member-remap-failed")
165
- return "high";
166
- if (issueConfidence === "uncertain")
167
- return "medium";
168
- }
169
- return undefined;
170
- }
171
- function computeConfidenceBreakdown(healthReport, provenance, remapFailureCount, skippedMemberCount) {
172
- const baseScore = 100;
173
- const penalties = [];
174
- let score = baseScore;
175
- if (healthReport) {
176
- if (!healthReport.overallHealthy) {
177
- penalties.push({ reason: "mapping-health", points: 30 });
178
- score -= 30;
179
- }
180
- if (!healthReport.tinyMappingsAvailable) {
181
- penalties.push({ reason: "tiny-mappings-unavailable", points: 20 });
182
- score -= 20;
183
- }
184
- if (!healthReport.memberRemapAvailable) {
185
- penalties.push({ reason: "member-remap-unavailable", points: 15 });
186
- score -= 15;
187
- }
188
- }
189
- if (provenance?.scopeFallback) {
190
- penalties.push({ reason: "scope-fallback", points: 10 });
191
- score -= 10;
192
- }
193
- if (provenance && provenance.requestedMapping !== provenance.mappingApplied) {
194
- penalties.push({ reason: "mapping-mismatch", points: 15 });
195
- score -= 15;
196
- }
197
- if (skippedMemberCount > 0) {
198
- penalties.push({ reason: "members-skipped", points: 25 });
199
- score -= 25;
200
- }
201
- const remapPenalty = Math.min(remapFailureCount * 2, 20);
202
- if (remapPenalty > 0) {
203
- penalties.push({ reason: "remap-failures", points: remapPenalty });
204
- score -= remapPenalty;
205
- }
206
- return {
207
- baseScore,
208
- score: Math.max(score, 0),
209
- penalties
210
- };
211
- }
212
- function summarizeResolvedMembers(resolvedMembers) {
213
- return {
214
- membersValidated: resolvedMembers.filter((member) => member.status === "resolved").length,
215
- membersSkipped: resolvedMembers.filter((member) => member.status === "skipped").length,
216
- membersMissing: resolvedMembers.filter((member) => member.status === "not-found").length
217
- };
218
- }
219
- function computeValidationStatus(summary) {
220
- if (summary.errors > 0 || summary.definiteErrors > 0) {
221
- return "invalid";
222
- }
223
- if (summary.warnings > 0 || summary.membersSkipped > 0) {
224
- return "partial";
225
- }
226
- return "full";
227
- }
228
- function buildQuickSummary(status, summary) {
229
- if (status === "full") {
230
- return `${summary.membersValidated} member(s) validated successfully.`;
231
- }
232
- return `${summary.definiteErrors} error(s), ${summary.uncertainErrors} uncertain, ${summary.warnings} warning(s). ${summary.membersValidated} validated, ${summary.membersSkipped} member(s) skipped, ${summary.membersMissing} member(s) missing.`;
233
- }
234
- function addSkippedMembers(parsed, resolvedMembers) {
235
- for (const inj of parsed.injections) {
236
- resolvedMembers.push({
237
- annotation: `@${inj.annotation}`,
238
- name: extractMethodName(inj.method),
239
- line: inj.line,
240
- status: "skipped"
241
- });
242
- }
243
- for (const shadow of parsed.shadows) {
244
- resolvedMembers.push({
245
- annotation: "@Shadow",
246
- name: shadow.name,
247
- line: shadow.line,
248
- status: "skipped"
249
- });
250
- }
251
- for (const accessor of parsed.accessors) {
252
- resolvedMembers.push({
253
- annotation: `@${accessor.annotation}`,
254
- name: accessor.targetName,
255
- line: accessor.line,
256
- status: "skipped"
257
- });
258
- }
259
- }
260
- export function refreshMixinValidationOutcome(result) {
261
- const memberSummary = result.resolvedMembers
262
- ? summarizeResolvedMembers(result.resolvedMembers)
263
- : {
264
- membersValidated: result.summary.membersValidated,
265
- membersSkipped: result.summary.membersSkipped,
266
- membersMissing: result.summary.membersMissing
267
- };
268
- result.summary = {
269
- ...result.summary,
270
- ...memberSummary
271
- };
272
- result.validationStatus = computeValidationStatus(result.summary);
273
- result.valid = result.summary.definiteErrors === 0;
274
- result.quickSummary = buildQuickSummary(result.validationStatus, result.summary);
275
- return result;
276
- }
277
- function validateInjection(inj, targetMembers, targetNames, issues, resolvedMembers, confidence, confidenceReason, remapFailedMembers, signatureFailedTargets, healthReport) {
278
- for (const targetName of targetNames) {
279
- const members = targetMembers.get(targetName);
280
- if (!members)
281
- continue;
282
- const methodNames = allMethodNames(members);
283
- // Strip owner prefix and JVM descriptor from the method reference
284
- const methodName = extractMethodName(inj.method);
285
- if (!methodNames.includes(methodName)) {
286
- const suggestions = suggestSimilar(methodName, methodNames);
287
- const descriptor = extractMethodDescriptor(inj.method);
288
- const descriptorHint = descriptor ? ` (descriptor: ${descriptor})` : "";
289
- // Determine if this is a remap artifact or signature unavailability
290
- const isRemapFailed = remapFailedMembers?.get(targetName)?.has(methodName);
291
- const isSigFailed = signatureFailedTargets?.has(targetName);
292
- const issueConfidence = isRemapFailed ? "uncertain" : confidence;
293
- const issueConfidenceReason = isRemapFailed
294
- ? `Member remap from obfuscated→mapping failed; name mismatch may be a remap artifact, not a true missing member.`
295
- : confidenceReason;
296
- const resolutionPath = isRemapFailed
297
- ? "member-remap-failed"
298
- : isSigFailed ? "source-signature-unavailable" : undefined;
299
- const memberDegraded = isRemapFailed && healthReport?.memberRemapAvailable === false;
300
- issues.push({
301
- severity: memberDegraded ? "warning" : "error",
302
- kind: "method-not-found",
303
- annotation: `@${inj.annotation}`,
304
- target: `${targetName}#${inj.method}`,
305
- message: `Method "${methodName}" not found in target class "${targetName}".${descriptorHint}${memberDegraded ? " (infrastructure degraded; may be false positive)" : ""}`,
306
- suggestions: suggestions.length > 0 ? suggestions : undefined,
307
- line: inj.line,
308
- confidence: issueConfidence,
309
- confidenceReason: issueConfidenceReason,
310
- resolutionPath,
311
- falsePositiveRisk: computeFalsePositiveRisk(healthReport, resolutionPath, issueConfidence)
312
- });
313
- resolvedMembers.push({
314
- annotation: `@${inj.annotation}`,
315
- name: methodName,
316
- line: inj.line,
317
- status: "not-found"
318
- });
319
- }
320
- else {
321
- resolvedMembers.push({
322
- annotation: `@${inj.annotation}`,
323
- name: methodName,
324
- line: inj.line,
325
- resolvedTo: `${targetName}#${methodName}`,
326
- status: "resolved"
327
- });
328
- }
329
- }
330
- }
331
- function validateShadow(shadow, targetMembers, targetNames, issues, resolvedMembers, confidence, confidenceReason, remapFailedMembers, signatureFailedTargets, healthReport) {
332
- for (const targetName of targetNames) {
333
- const members = targetMembers.get(targetName);
334
- if (!members)
335
- continue;
336
- const isRemapFailed = remapFailedMembers?.get(targetName)?.has(shadow.name);
337
- const isSigFailed = signatureFailedTargets?.has(targetName);
338
- const issueConfidence = isRemapFailed ? "uncertain" : confidence;
339
- const issueConfidenceReason = isRemapFailed
340
- ? `Member remap from obfuscated→mapping failed; name mismatch may be a remap artifact, not a true missing member.`
341
- : confidenceReason;
342
- const resolutionPath = isRemapFailed
343
- ? "member-remap-failed"
344
- : isSigFailed ? "source-signature-unavailable" : undefined;
345
- const memberDegraded = isRemapFailed && healthReport?.memberRemapAvailable === false;
346
- if (shadow.kind === "field") {
347
- const fieldNames = allFieldNames(members);
348
- if (!fieldNames.includes(shadow.name)) {
349
- const suggestions = suggestSimilar(shadow.name, fieldNames);
350
- issues.push({
351
- severity: memberDegraded ? "warning" : "error",
352
- kind: "field-not-found",
353
- annotation: "@Shadow",
354
- target: `${targetName}#${shadow.name}`,
355
- message: `Field "${shadow.name}" not found in target class "${targetName}" (${fieldNames.length} field(s) available).${memberDegraded ? " (infrastructure degraded; may be false positive)" : ""}`,
356
- suggestions: suggestions.length > 0 ? suggestions : undefined,
357
- line: shadow.line,
358
- confidence: issueConfidence,
359
- confidenceReason: issueConfidenceReason,
360
- resolutionPath,
361
- falsePositiveRisk: computeFalsePositiveRisk(healthReport, resolutionPath, issueConfidence)
362
- });
363
- resolvedMembers.push({ annotation: "@Shadow", name: shadow.name, line: shadow.line, status: "not-found" });
364
- }
365
- else {
366
- resolvedMembers.push({ annotation: "@Shadow", name: shadow.name, line: shadow.line, resolvedTo: `${targetName}#${shadow.name}`, status: "resolved" });
367
- }
368
- }
369
- else {
370
- const methodNames = allMethodNames(members);
371
- if (!methodNames.includes(shadow.name)) {
372
- const suggestions = suggestSimilar(shadow.name, methodNames);
373
- issues.push({
374
- severity: memberDegraded ? "warning" : "error",
375
- kind: "method-not-found",
376
- annotation: "@Shadow",
377
- target: `${targetName}#${shadow.name}`,
378
- message: `Method "${shadow.name}" not found in target class "${targetName}" (${methodNames.length} method(s) available).${memberDegraded ? " (infrastructure degraded; may be false positive)" : ""}`,
379
- suggestions: suggestions.length > 0 ? suggestions : undefined,
380
- line: shadow.line,
381
- confidence: issueConfidence,
382
- confidenceReason: issueConfidenceReason,
383
- resolutionPath,
384
- falsePositiveRisk: computeFalsePositiveRisk(healthReport, resolutionPath, issueConfidence)
385
- });
386
- resolvedMembers.push({ annotation: "@Shadow", name: shadow.name, line: shadow.line, status: "not-found" });
387
- }
388
- else {
389
- resolvedMembers.push({ annotation: "@Shadow", name: shadow.name, line: shadow.line, resolvedTo: `${targetName}#${shadow.name}`, status: "resolved" });
390
- }
391
- }
392
- }
393
- }
394
- function validateAccessor(accessor, targetMembers, targetNames, issues, resolvedMembers, confidence, confidenceReason, remapFailedMembers, signatureFailedTargets, healthReport) {
395
- for (const targetName of targetNames) {
396
- const members = targetMembers.get(targetName);
397
- if (!members)
398
- continue;
399
- const candidateNames = accessor.annotation === "Invoker"
400
- ? allMethodNames(members)
401
- : allFieldNames(members);
402
- if (!candidateNames.includes(accessor.targetName)) {
403
- const isRemapFailed = remapFailedMembers?.get(targetName)?.has(accessor.targetName);
404
- const isSigFailed = signatureFailedTargets?.has(targetName);
405
- const issueConfidence = isRemapFailed ? "uncertain" : confidence;
406
- const issueConfidenceReason = isRemapFailed
407
- ? `Member remap from obfuscated→mapping failed; name mismatch may be a remap artifact, not a true missing member.`
408
- : confidenceReason;
409
- const resolutionPath = isRemapFailed
410
- ? "member-remap-failed"
411
- : isSigFailed ? "source-signature-unavailable" : undefined;
412
- const memberDegraded = isRemapFailed && healthReport?.memberRemapAvailable === false;
413
- const suggestions = suggestSimilar(accessor.targetName, candidateNames);
414
- const inferenceHint = accessor.targetName !== accessor.name
415
- ? ` (inferred "${accessor.targetName}" from "${accessor.name}" via prefix removal)`
416
- : "";
417
- issues.push({
418
- severity: memberDegraded ? "warning" : "error",
419
- kind: accessor.annotation === "Invoker" ? "method-not-found" : "field-not-found",
420
- annotation: `@${accessor.annotation}`,
421
- target: `${targetName}#${accessor.targetName}`,
422
- message: `Target "${accessor.targetName}" not found in class "${targetName}".${inferenceHint}${memberDegraded ? " (infrastructure degraded; may be false positive)" : ""}`,
423
- suggestions: suggestions.length > 0 ? suggestions : undefined,
424
- line: accessor.line,
425
- confidence: issueConfidence,
426
- confidenceReason: issueConfidenceReason,
427
- resolutionPath,
428
- falsePositiveRisk: computeFalsePositiveRisk(healthReport, resolutionPath, issueConfidence)
429
- });
430
- resolvedMembers.push({ annotation: `@${accessor.annotation}`, name: accessor.targetName, line: accessor.line, status: "not-found" });
431
- }
432
- else {
433
- resolvedMembers.push({ annotation: `@${accessor.annotation}`, name: accessor.targetName, line: accessor.line, resolvedTo: `${targetName}#${accessor.targetName}`, status: "resolved" });
434
- }
435
- }
436
- }
437
- export function validateParsedMixin(parsed, targetMembers, warnings, provenance, confidence, mappingFailedTargets, explain, remapFailedMembers, signatureFailedTargets, suggestedCallContext, warningMode, healthReport, symbolExistsButSignatureFailed) {
438
- const issues = [];
439
- const targetNames = parsed.targets.map((t) => t.className);
440
- const confidenceReason = confidence === "uncertain"
441
- ? `Mapping fallback: requested "${provenance?.requestedMapping}" but applied "${provenance?.mappingApplied}".`
442
- : confidence === "likely"
443
- ? "Some members could not be remapped."
444
- : undefined;
445
- const resolvedMembers = [];
446
- // Check target classes exist
447
- for (const target of parsed.targets) {
448
- if (!targetMembers.has(target.className)) {
449
- if (mappingFailedTargets?.has(target.className)) {
450
- // Mapping failure — report as warning with distinct kind
451
- issues.push({
452
- severity: "warning",
453
- kind: "target-mapping-failed",
454
- annotation: "@Mixin",
455
- target: target.className,
456
- message: `Could not map target class "${target.className}" to obfuscated namespace; class may still exist under a different mapping.`,
457
- confidence: "uncertain",
458
- confidenceReason: `Mapping from "${provenance?.requestedMapping}" to obfuscated failed for this class.`,
459
- category: "mapping",
460
- resolutionPath: "target-mapping-failed",
461
- falsePositiveRisk: healthReport?.overallHealthy === false ? "high" : "medium"
462
- });
463
- }
464
- else if (symbolExistsButSignatureFailed?.has(target.className)) {
465
- // Symbol exists in mapping graph but getSignature failed — tool limitation, not code issue
466
- issues.push({
467
- severity: "warning",
468
- kind: "validation-incomplete",
469
- annotation: "@Mixin",
470
- target: target.className,
471
- message: `Target class "${target.className}" exists in mapping data but could not be loaded from game jar (tool limitation). Members not validated.`,
472
- confidence: "uncertain",
473
- confidenceReason: "Class exists in mapping graph but bytecode signature extraction failed.",
474
- category: "resolution",
475
- resolutionPath: "source-signature-unavailable",
476
- issueOrigin: "tool_issue",
477
- falsePositiveRisk: "high"
478
- });
479
- addSkippedMembers(parsed, resolvedMembers);
480
- }
481
- else if (signatureFailedTargets?.has(target.className)) {
482
- issues.push({
483
- severity: "warning",
484
- kind: "validation-incomplete",
485
- annotation: "@Mixin",
486
- target: target.className,
487
- message: `Target class "${target.className}" could not load enough target metadata for reliable validation. Members were not validated.`,
488
- confidence: "uncertain",
489
- confidenceReason: "Target bytecode could not be loaded and fallback existence checks were unavailable.",
490
- category: "resolution",
491
- resolutionPath: "source-signature-unavailable",
492
- issueOrigin: "tool_issue",
493
- falsePositiveRisk: "high"
494
- });
495
- addSkippedMembers(parsed, resolvedMembers);
496
- }
497
- else {
498
- issues.push({
499
- severity: "error",
500
- kind: "target-not-found",
501
- annotation: "@Mixin",
502
- target: target.className,
503
- message: `Target class "${target.className}" not found in game jar.`,
504
- confidence,
505
- confidenceReason,
506
- category: "validation",
507
- resolutionPath: "target-class-missing"
508
- });
509
- }
510
- }
511
- }
512
- // Only validate members against targets that were resolved
513
- const resolvedTargetNames = targetNames.filter((t) => targetMembers.has(t));
514
- for (const inj of parsed.injections) {
515
- validateInjection(inj, targetMembers, resolvedTargetNames, issues, resolvedMembers, confidence, confidenceReason, remapFailedMembers, signatureFailedTargets, healthReport);
516
- }
517
- for (const shadow of parsed.shadows) {
518
- validateShadow(shadow, targetMembers, resolvedTargetNames, issues, resolvedMembers, confidence, confidenceReason, remapFailedMembers, signatureFailedTargets, healthReport);
519
- }
520
- for (const accessor of parsed.accessors) {
521
- validateAccessor(accessor, targetMembers, resolvedTargetNames, issues, resolvedMembers, confidence, confidenceReason, remapFailedMembers, signatureFailedTargets, healthReport);
522
- }
523
- // Add parse warnings — escalate @Accessor/@Invoker/@Shadow parse failures to issues
524
- for (const pw of parsed.parseWarnings) {
525
- if (/@(Accessor|Invoker|Shadow)\b/.test(pw)) {
526
- const annotation = pw.includes("@Accessor") ? "@Accessor"
527
- : pw.includes("@Invoker") ? "@Invoker" : "@Shadow";
528
- issues.push({
529
- severity: "warning",
530
- kind: "unknown-annotation",
531
- annotation,
532
- target: parsed.className,
533
- message: pw,
534
- confidence: "uncertain",
535
- confidenceReason: "Parser could not extract member declaration; the annotation may be valid.",
536
- category: "parse",
537
- issueOrigin: "parser_limitation",
538
- falsePositiveRisk: "high"
539
- });
540
- }
541
- else {
542
- warnings.push(pw);
543
- }
544
- }
545
- // Contradiction detection: if some same-annotation members resolved OK but parse failed for others, note it
546
- const resolvedAnnotations = new Set();
547
- for (const member of resolvedMembers) {
548
- if (member.status === "resolved") {
549
- resolvedAnnotations.add(member.annotation);
550
- }
551
- }
552
- let errorCount = 0;
553
- let warningCount = 0;
554
- let definiteErrors = 0;
555
- let uncertainErrors = 0;
556
- let resolutionErrors = 0;
557
- let parseWarningCount = 0;
558
- for (const issue of issues) {
559
- if (issue.category === "parse" && resolvedAnnotations.has(issue.annotation)) {
560
- issue.message += " (Note: other members with the same annotation resolved successfully.)";
561
- }
562
- if (!issue.category) {
563
- issue.category = issue.resolutionPath ? "resolution" : "validation";
564
- }
565
- if (!issue.issueOrigin) {
566
- if (issue.category === "parse") {
567
- issue.issueOrigin = "parser_limitation";
568
- }
569
- else {
570
- issue.issueOrigin = issue.resolutionPath && TOOL_RESOLUTION_PATHS.includes(issue.resolutionPath)
571
- ? "tool_issue"
572
- : "code_issue";
573
- }
574
- }
575
- if (issue.severity === "error") {
576
- errorCount++;
577
- if (issue.confidence === "uncertain") {
578
- uncertainErrors++;
579
- }
580
- else {
581
- definiteErrors++;
582
- }
583
- }
584
- else {
585
- warningCount++;
586
- }
587
- if (issue.resolutionPath != null) {
588
- resolutionErrors++;
589
- }
590
- if (issue.category === "parse") {
591
- parseWarningCount++;
592
- }
593
- }
594
- // Enrich issues with explanations and suggested calls when explain=true
595
- if (explain) {
596
- const version = provenance?.version;
597
- const mapping = provenance?.requestedMapping;
598
- const symbolLookupContext = {};
599
- if (suggestedCallContext?.sourcePriority) {
600
- symbolLookupContext.sourcePriority = suggestedCallContext.sourcePriority;
601
- }
602
- const classSourceContext = {};
603
- if (suggestedCallContext?.scope)
604
- classSourceContext.scope = suggestedCallContext.scope;
605
- if (suggestedCallContext?.sourcePriority)
606
- classSourceContext.sourcePriority = suggestedCallContext.sourcePriority;
607
- if (suggestedCallContext?.projectPath)
608
- classSourceContext.projectPath = suggestedCallContext.projectPath;
609
- if (suggestedCallContext?.mapping)
610
- classSourceContext.mapping = suggestedCallContext.mapping;
611
- for (const issue of issues) {
612
- switch (issue.kind) {
613
- case "target-not-found":
614
- issue.explanation = `The class "${issue.target}" was not found in the game jar. It may be misspelled, from a different version, or use a different mapping namespace.`;
615
- if (version && mapping) {
616
- issue.suggestedCall = {
617
- tool: "check-symbol-exists",
618
- params: { kind: "class", name: issue.target, version, sourceMapping: mapping, nameMode: "auto", ...symbolLookupContext }
619
- };
620
- }
621
- break;
622
- case "validation-incomplete":
623
- issue.explanation = `Target metadata for "${issue.target}" could not be loaded reliably, so validation was only partial. This usually indicates a tool or environment limitation rather than a confirmed code error.`;
624
- if (version) {
625
- issue.suggestedCall = {
626
- tool: "get-class-source",
627
- params: {
628
- className: issue.target,
629
- target: { type: "resolve", kind: "version", value: version },
630
- ...(mapping ? { mapping } : {}),
631
- mode: "metadata",
632
- ...classSourceContext
633
- }
634
- };
635
- }
636
- break;
637
- case "target-mapping-failed":
638
- issue.explanation = `Mapping lookup failed for "${issue.target}". The class may exist under a different name in the target namespace.`;
639
- if (version && mapping) {
640
- issue.suggestedCall = {
641
- tool: "check-symbol-exists",
642
- params: { kind: "class", name: issue.target, version, sourceMapping: mapping, nameMode: "auto", ...symbolLookupContext }
643
- };
644
- }
645
- break;
646
- case "method-not-found": {
647
- const parts = issue.target.split("#");
648
- const className = parts[0] ?? issue.target;
649
- issue.explanation = `The method was not found in the target class. It may be named differently in the current mapping, or might not exist in this version.`;
650
- if (version) {
651
- issue.suggestedCall = {
652
- tool: "get-class-source",
653
- params: {
654
- className,
655
- target: { type: "resolve", kind: "version", value: version },
656
- ...(mapping ? { mapping } : {}),
657
- mode: "metadata",
658
- ...classSourceContext
659
- }
660
- };
661
- }
662
- break;
663
- }
664
- case "field-not-found": {
665
- const parts = issue.target.split("#");
666
- const ownerName = parts[0] ?? issue.target;
667
- const fieldName = parts[1] ?? issue.target;
668
- issue.explanation = `The field "${fieldName}" was not found in the target class. Verify the field name matches the expected mapping namespace.`;
669
- if (version && mapping) {
670
- issue.suggestedCall = {
671
- tool: "check-symbol-exists",
672
- params: { kind: "field", owner: ownerName, name: fieldName, version, sourceMapping: mapping, ...symbolLookupContext }
673
- };
674
- }
675
- break;
676
- }
677
- }
678
- }
679
- }
680
- const structuredWarnings = warnings.map(classifyStructuredWarning);
681
- // Warning aggregation mode
682
- let aggregatedWarnings;
683
- let outputWarnings = warnings;
684
- let outputStructuredWarnings = structuredWarnings.length > 0 ? structuredWarnings : undefined;
685
- if (warningMode === "aggregated" && structuredWarnings.length > 0) {
686
- const groupMap = new Map();
687
- for (const sw of structuredWarnings) {
688
- const cat = sw.category ?? "validation";
689
- const existing = groupMap.get(cat);
690
- if (existing) {
691
- existing.count++;
692
- if (existing.samples.length < 2) {
693
- existing.samples.push(sw.message);
694
- }
695
- }
696
- else {
697
- groupMap.set(cat, { count: 1, samples: [sw.message] });
698
- }
699
- }
700
- aggregatedWarnings = [...groupMap.entries()].map(([category, { count, samples }]) => ({
701
- category,
702
- count,
703
- samples
704
- }));
705
- outputWarnings = [];
706
- outputStructuredWarnings = undefined;
707
- }
708
- // Compute confidence score
709
- const remapFailureCount = provenance?.remapFailures ?? 0;
710
- const memberSummary = summarizeResolvedMembers(resolvedMembers);
711
- const confidenceBreakdown = healthReport
712
- ? computeConfidenceBreakdown(healthReport, provenance, remapFailureCount, memberSummary.membersSkipped)
713
- : undefined;
714
- const confidenceScore = confidenceBreakdown?.score;
715
- const total = parsed.injections.length + parsed.shadows.length + parsed.accessors.length;
716
- const summary = {
717
- injections: parsed.injections.length,
718
- shadows: parsed.shadows.length,
719
- accessors: parsed.accessors.length,
720
- total,
721
- ...memberSummary,
722
- errors: errorCount,
723
- warnings: warningCount,
724
- definiteErrors,
725
- uncertainErrors,
726
- resolutionErrors,
727
- parseWarnings: parseWarningCount
728
- };
729
- const validationStatus = computeValidationStatus(summary);
730
- const quickSummary = buildQuickSummary(validationStatus, summary);
731
- return {
732
- className: parsed.className,
733
- targets: targetNames,
734
- priority: parsed.priority,
735
- valid: definiteErrors === 0,
736
- validationStatus,
737
- issues,
738
- summary,
739
- provenance,
740
- warnings: outputWarnings,
741
- structuredWarnings: outputStructuredWarnings,
742
- aggregatedWarnings,
743
- resolvedMembers: resolvedMembers.length > 0 ? resolvedMembers : undefined,
744
- toolHealth: healthReport,
745
- confidenceScore,
746
- confidenceBreakdown,
747
- quickSummary
748
- };
749
- }
750
- /* ------------------------------------------------------------------ */
751
- /* Access Widener validation */
752
- /* ------------------------------------------------------------------ */
753
- export function validateParsedAccessWidener(parsed, membersByClass, warnings, options) {
754
- warnings.push(...parsed.parseWarnings);
755
- const validatedEntries = [];
756
- let validCount = 0;
757
- let invalidCount = 0;
758
- for (const entry of parsed.entries) {
759
- const ownerFqn = entry.target.replace(/\//g, ".");
760
- if (entry.targetKind === "class") {
761
- const members = membersByClass.get(ownerFqn);
762
- if (members) {
763
- const runtimeAccess = accessLevelFromFlags(members.classAccessFlags);
764
- validatedEntries.push({
765
- ...entry,
766
- valid: true,
767
- ...(options?.includeRuntimeEvidence
768
- ? {
769
- resolvedInRuntime: true,
770
- ...(runtimeAccess
771
- ? { resolvedRuntimeAccess: runtimeAccess }
772
- : {})
773
- }
774
- : {})
775
- });
776
- validCount++;
777
- }
778
- else {
779
- validatedEntries.push({
780
- ...entry,
781
- valid: false,
782
- issue: `Class "${ownerFqn}" not found in game jar.`,
783
- ...(options?.includeRuntimeEvidence ? { resolvedInRuntime: false } : {})
784
- });
785
- invalidCount++;
786
- }
787
- continue;
788
- }
789
- // method or field
790
- const members = membersByClass.get(ownerFqn);
791
- if (!members) {
792
- validatedEntries.push({
793
- ...entry,
794
- valid: false,
795
- issue: `Owner class "${ownerFqn}" not found in game jar.`,
796
- ...(options?.includeRuntimeEvidence ? { resolvedInRuntime: false } : {})
797
- });
798
- invalidCount++;
799
- continue;
800
- }
801
- if (entry.targetKind === "method") {
802
- const methodNames = allMethodNames(members);
803
- const matchedMember = members.methods.find((m) => m.name === entry.name && (!entry.descriptor || m.jvmDescriptor === entry.descriptor)) ?? members.constructors.find((m) => m.name === entry.name && (!entry.descriptor || m.jvmDescriptor === entry.descriptor));
804
- const found = matchedMember != null;
805
- if (found) {
806
- const runtimeMember = matchedMember;
807
- const runtimeAccess = accessLevelFromFlags(runtimeMember.accessFlags);
808
- validatedEntries.push({
809
- ...entry,
810
- valid: true,
811
- ...(options?.includeRuntimeEvidence
812
- ? {
813
- resolvedInRuntime: true,
814
- ...(runtimeAccess
815
- ? { resolvedRuntimeAccess: runtimeAccess }
816
- : {}),
817
- ...(runtimeMember.jvmDescriptor
818
- ? { resolvedRuntimeJvmDescriptor: runtimeMember.jvmDescriptor }
819
- : {}),
820
- ...(runtimeMember.javaSignature
821
- ? { resolvedRuntimeJavaSignature: runtimeMember.javaSignature }
822
- : {})
823
- }
824
- : {})
825
- });
826
- validCount++;
827
- }
828
- else {
829
- const suggestions = entry.name ? suggestSimilar(entry.name, methodNames) : [];
830
- validatedEntries.push({
831
- ...entry,
832
- valid: false,
833
- issue: `Method "${entry.name}" not found in class "${ownerFqn}".`,
834
- suggestions: suggestions.length > 0 ? suggestions : undefined,
835
- ...(options?.includeRuntimeEvidence ? { resolvedInRuntime: false } : {})
836
- });
837
- invalidCount++;
838
- }
839
- }
840
- else {
841
- // field
842
- const fieldNames = allFieldNames(members);
843
- const matchedMember = members.fields.find((m) => m.name === entry.name && (!entry.descriptor || m.jvmDescriptor === entry.descriptor));
844
- const found = matchedMember != null;
845
- if (found) {
846
- const runtimeMember = matchedMember;
847
- const runtimeAccess = accessLevelFromFlags(runtimeMember.accessFlags);
848
- validatedEntries.push({
849
- ...entry,
850
- valid: true,
851
- ...(options?.includeRuntimeEvidence
852
- ? {
853
- resolvedInRuntime: true,
854
- ...(runtimeAccess
855
- ? { resolvedRuntimeAccess: runtimeAccess }
856
- : {}),
857
- ...(runtimeMember.jvmDescriptor
858
- ? { resolvedRuntimeJvmDescriptor: runtimeMember.jvmDescriptor }
859
- : {}),
860
- ...(runtimeMember.javaSignature
861
- ? { resolvedRuntimeJavaSignature: runtimeMember.javaSignature }
862
- : {})
863
- }
864
- : {})
865
- });
866
- validCount++;
867
- }
868
- else {
869
- const suggestions = entry.name ? suggestSimilar(entry.name, fieldNames) : [];
870
- validatedEntries.push({
871
- ...entry,
872
- valid: false,
873
- issue: `Field "${entry.name}" not found in class "${ownerFqn}".`,
874
- suggestions: suggestions.length > 0 ? suggestions : undefined,
875
- ...(options?.includeRuntimeEvidence ? { resolvedInRuntime: false } : {})
876
- });
877
- invalidCount++;
878
- }
879
- }
880
- }
881
- return {
882
- headerVersion: parsed.headerVersion,
883
- namespace: parsed.namespace,
884
- valid: invalidCount === 0,
885
- entries: validatedEntries,
886
- summary: {
887
- total: parsed.entries.length,
888
- valid: validCount,
889
- invalid: invalidCount
890
- },
891
- warnings
892
- };
893
- }
894
- export function validateParsedAccessTransformer(parsed, membersByClass, warnings, options) {
895
- warnings.push(...parsed.parseWarnings);
896
- const validatedEntries = [];
897
- let validCount = 0;
898
- let invalidCount = 0;
899
- for (const entry of parsed.entries) {
900
- const ownerFqn = entry.owner;
901
- const members = membersByClass.get(ownerFqn);
902
- if (entry.targetKind === "class") {
903
- if (!members) {
904
- validatedEntries.push({
905
- ...entry,
906
- valid: false,
907
- issue: `Class "${ownerFqn}" not found in runtime jar.`,
908
- ...(options?.includeRuntimeEvidence ? { resolvedInRuntime: false } : {})
909
- });
910
- invalidCount++;
911
- continue;
912
- }
913
- const runtimeAccess = accessLevelFromFlags(members.classAccessFlags);
914
- validatedEntries.push({
915
- ...entry,
916
- valid: true,
917
- ...(options?.includeRuntimeEvidence
918
- ? {
919
- resolvedInRuntime: true,
920
- ...(runtimeAccess ? { resolvedRuntimeAccess: runtimeAccess } : {})
921
- }
922
- : {})
923
- });
924
- validCount++;
925
- continue;
926
- }
927
- if (!members) {
928
- validatedEntries.push({
929
- ...entry,
930
- valid: false,
931
- issue: `Owner class "${ownerFqn}" not found in runtime jar.`,
932
- ...(options?.includeRuntimeEvidence ? { resolvedInRuntime: false } : {})
933
- });
934
- invalidCount++;
935
- continue;
936
- }
937
- if (entry.targetKind === "field") {
938
- const fieldNames = allFieldNames(members);
939
- const matchedField = members.fields.find((member) => member.name === entry.name);
940
- if (!matchedField) {
941
- const suggestions = entry.name ? suggestSimilar(entry.name, fieldNames) : [];
942
- validatedEntries.push({
943
- ...entry,
944
- valid: false,
945
- issue: `Field "${entry.name}" not found in class "${ownerFqn}".`,
946
- ...(suggestions.length > 0 ? { suggestions } : {}),
947
- ...(options?.includeRuntimeEvidence ? { resolvedInRuntime: false } : {})
948
- });
949
- invalidCount++;
950
- continue;
951
- }
952
- const runtimeAccess = accessLevelFromFlags(matchedField.accessFlags);
953
- validatedEntries.push({
954
- ...entry,
955
- valid: true,
956
- ...(options?.includeRuntimeEvidence
957
- ? {
958
- resolvedInRuntime: true,
959
- ...(runtimeAccess ? { resolvedRuntimeAccess: runtimeAccess } : {}),
960
- ...(matchedField.jvmDescriptor ? { resolvedRuntimeJvmDescriptor: matchedField.jvmDescriptor } : {}),
961
- ...(matchedField.javaSignature ? { resolvedRuntimeJavaSignature: matchedField.javaSignature } : {})
962
- }
963
- : {})
964
- });
965
- validCount++;
966
- continue;
967
- }
968
- const methodNames = allMethodNames(members);
969
- const matchedMethod = members.methods.find((member) => member.name === entry.name && member.jvmDescriptor === entry.descriptor) ?? members.constructors.find((member) => member.name === entry.name && member.jvmDescriptor === entry.descriptor);
970
- if (!matchedMethod) {
971
- const suggestions = entry.name ? suggestSimilar(entry.name, methodNames) : [];
972
- validatedEntries.push({
973
- ...entry,
974
- valid: false,
975
- issue: `Method "${entry.name}" not found in class "${ownerFqn}".`,
976
- ...(suggestions.length > 0 ? { suggestions } : {}),
977
- ...(options?.includeRuntimeEvidence ? { resolvedInRuntime: false } : {})
978
- });
979
- invalidCount++;
980
- continue;
981
- }
982
- const runtimeAccess = accessLevelFromFlags(matchedMethod.accessFlags);
983
- validatedEntries.push({
984
- ...entry,
985
- valid: true,
986
- ...(options?.includeRuntimeEvidence
987
- ? {
988
- resolvedInRuntime: true,
989
- ...(runtimeAccess ? { resolvedRuntimeAccess: runtimeAccess } : {}),
990
- ...(matchedMethod.jvmDescriptor ? { resolvedRuntimeJvmDescriptor: matchedMethod.jvmDescriptor } : {}),
991
- ...(matchedMethod.javaSignature ? { resolvedRuntimeJavaSignature: matchedMethod.javaSignature } : {})
992
- }
993
- : {})
994
- });
995
- validCount++;
996
- }
997
- return {
998
- valid: invalidCount === 0,
999
- entries: validatedEntries,
1000
- summary: {
1001
- total: parsed.entries.length,
1002
- valid: validCount,
1003
- invalid: invalidCount
1004
- },
1005
- warnings
1006
- };
1007
- }
6
+ export { loadMixinStageBudgets } from "./mixin/types.js";
7
+ export { accessLevelFromFlags, buildQuickSummary, computeConfidenceBreakdown, computeFalsePositiveRisk, computeValidationStatus, extractMethodDescriptor, extractMethodName, levenshteinDistance, refreshMixinValidationOutcome, suggestSimilar, summarizeResolvedMembers } from "./mixin/helpers.js";
8
+ export { validateAccessor, validateInjection, validateShadow } from "./mixin/annotation-validators.js";
9
+ export { validateParsedMixin } from "./mixin/parsed-validator.js";
10
+ export { validateParsedAccessTransformer, validateParsedAccessWidener } from "./mixin/access-validators.js";
1008
11
  //# sourceMappingURL=mixin-validator.js.map