rigortype 0.4.8 → 0.4.9

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 (349) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/docs/handbook/01-getting-started.md +1 -1
  4. data/docs/handbook/04-tuples-and-shapes.md +6 -1
  5. data/docs/handbook/12-lightweight-hkt.md +1 -1
  6. data/docs/handbook/appendix-typescript.md +28 -17
  7. data/docs/manual/02-cli-reference.md +10 -0
  8. data/docs/manual/03-configuration.md +1 -1
  9. data/docs/manual/04-diagnostics.md +1 -1
  10. data/docs/manual/10-mcp-server.md +122 -10
  11. data/docs/manual/plugins/rigor-activerecord.md +7 -0
  12. data/lib/rigor/analysis/check_rules/always_raises.rb +95 -0
  13. data/lib/rigor/analysis/check_rules/always_truthy_condition_collector.rb +32 -2
  14. data/lib/rigor/analysis/check_rules/argument_type.rb +802 -0
  15. data/lib/rigor/analysis/check_rules/call_facts.rb +2 -2
  16. data/lib/rigor/analysis/check_rules/dead_assignment_collector.rb +30 -1
  17. data/lib/rigor/analysis/check_rules/declaration_sourced_guard.rb +4 -5
  18. data/lib/rigor/analysis/check_rules/duplicate_hash_key_collector.rb +34 -0
  19. data/lib/rigor/analysis/check_rules/ivar_write_collector.rb +131 -4
  20. data/lib/rigor/analysis/check_rules/nil_receiver.rb +195 -0
  21. data/lib/rigor/analysis/check_rules/override_param_narrowed.rb +111 -0
  22. data/lib/rigor/analysis/check_rules/override_return_widened.rb +88 -0
  23. data/lib/rigor/analysis/check_rules/override_support.rb +246 -0
  24. data/lib/rigor/analysis/check_rules/override_visibility.rb +135 -0
  25. data/lib/rigor/analysis/check_rules/published_constant_guard.rb +75 -31
  26. data/lib/rigor/analysis/check_rules/raise_non_exception.rb +198 -0
  27. data/lib/rigor/analysis/check_rules/receiver_predicates.rb +576 -0
  28. data/lib/rigor/analysis/check_rules/return_in_ensure_collector.rb +52 -4
  29. data/lib/rigor/analysis/check_rules/return_type.rb +225 -0
  30. data/lib/rigor/analysis/check_rules/rigor_testing.rb +119 -0
  31. data/lib/rigor/analysis/check_rules/rule_ids.rb +7 -7
  32. data/lib/rigor/analysis/check_rules/rule_walk.rb +4 -3
  33. data/lib/rigor/analysis/check_rules/self_closedness_scanner.rb +2 -0
  34. data/lib/rigor/analysis/check_rules/self_undefined_method.rb +165 -0
  35. data/lib/rigor/analysis/check_rules/shadowed_rescue_collector.rb +34 -0
  36. data/lib/rigor/analysis/check_rules/source_arity.rb +2 -2
  37. data/lib/rigor/analysis/check_rules/special_global_write.rb +256 -0
  38. data/lib/rigor/analysis/check_rules/suppression.rb +275 -0
  39. data/lib/rigor/analysis/check_rules/undefined_method.rb +882 -0
  40. data/lib/rigor/analysis/check_rules/unreachable_branch.rb +97 -0
  41. data/lib/rigor/analysis/check_rules/unreachable_clause_collector.rb +42 -0
  42. data/lib/rigor/analysis/check_rules/unresolved_toplevel.rb +140 -0
  43. data/lib/rigor/analysis/check_rules/visibility_mismatch.rb +252 -0
  44. data/lib/rigor/analysis/check_rules/void_value_use_collector.rb +27 -0
  45. data/lib/rigor/analysis/check_rules/wrong_arity.rb +303 -0
  46. data/lib/rigor/analysis/check_rules.rb +66 -4931
  47. data/lib/rigor/analysis/dependency_recorder.rb +1 -1
  48. data/lib/rigor/analysis/dependency_source_inference/builder.rb +2 -4
  49. data/lib/rigor/analysis/dependency_source_inference/gem_resolver.rb +1 -2
  50. data/lib/rigor/analysis/dependency_source_inference/walker.rb +15 -15
  51. data/lib/rigor/analysis/incremental_session.rb +4 -4
  52. data/lib/rigor/analysis/path_expansion.rb +1 -1
  53. data/lib/rigor/analysis/plugin_fact_fingerprint.rb +5 -5
  54. data/lib/rigor/analysis/reachability/graph.rb +2 -3
  55. data/lib/rigor/analysis/reachability/plugin_roots.rb +2 -2
  56. data/lib/rigor/analysis/reachability/scan.rb +2 -2
  57. data/lib/rigor/analysis/rule_catalog.rb +2 -1
  58. data/lib/rigor/analysis/run_cache_key.rb +9 -8
  59. data/lib/rigor/analysis/runner/buffer_pool_dispatcher.rb +2 -2
  60. data/lib/rigor/analysis/runner/dependency_rows.rb +206 -0
  61. data/lib/rigor/analysis/runner/diagnostic_aggregator.rb +24 -22
  62. data/lib/rigor/analysis/runner/effect_cache_entries.rb +69 -0
  63. data/lib/rigor/analysis/runner/pool_coordinator.rb +6 -8
  64. data/lib/rigor/analysis/runner/project_pre_passes.rb +3 -5
  65. data/lib/rigor/analysis/runner/scope_seed.rb +144 -0
  66. data/lib/rigor/analysis/runner.rb +49 -296
  67. data/lib/rigor/analysis/template_unit_collector.rb +1 -1
  68. data/lib/rigor/analysis/template_units.rb +10 -10
  69. data/lib/rigor/analysis/worker_session.rb +7 -7
  70. data/lib/rigor/bleeding_edge.rb +3 -2
  71. data/lib/rigor/builtins/hkt_builtins.rb +17 -17
  72. data/lib/rigor/builtins/imported_refinements.rb +8 -16
  73. data/lib/rigor/builtins/regex_refinement.rb +3 -3
  74. data/lib/rigor/builtins/static_return_refinements.rb +143 -19
  75. data/lib/rigor/cache/incremental_snapshot.rb +21 -8
  76. data/lib/rigor/cache/rbs_descriptor.rb +18 -1
  77. data/lib/rigor/cli/coverage_renderer.rb +15 -1
  78. data/lib/rigor/cli/coverage_report.rb +19 -1
  79. data/lib/rigor/cli/diagnostic_formats.rb +3 -2
  80. data/lib/rigor/cli/docs_command.rb +5 -5
  81. data/lib/rigor/cli/effects_command.rb +7 -6
  82. data/lib/rigor/cli/fused_protection_report.rb +7 -7
  83. data/lib/rigor/cli/lsp_command.rb +1 -1
  84. data/lib/rigor/cli/mcp_command.rb +5 -2
  85. data/lib/rigor/cli/options.rb +4 -0
  86. data/lib/rigor/cli/plugins_command.rb +1 -1
  87. data/lib/rigor/cli/sig_gen_command.rb +1 -1
  88. data/lib/rigor/cli/skill_command.rb +5 -4
  89. data/lib/rigor/cli/triage_renderer.rb +3 -2
  90. data/lib/rigor/cli/unused_command.rb +4 -4
  91. data/lib/rigor/cli.rb +14 -0
  92. data/lib/rigor/configuration/coercion.rb +418 -0
  93. data/lib/rigor/configuration/defaults.rb +248 -0
  94. data/lib/rigor/configuration/dependencies.rb +1 -1
  95. data/lib/rigor/configuration/loader.rb +354 -0
  96. data/lib/rigor/configuration/severity_profile.rb +4 -4
  97. data/lib/rigor/configuration.rb +51 -860
  98. data/lib/rigor/effects/attribution.rb +1 -1
  99. data/lib/rigor/effects/effect_table.rb +1 -1
  100. data/lib/rigor/effects/identity.rb +3 -3
  101. data/lib/rigor/effects/local_ownership.rb +2 -2
  102. data/lib/rigor/effects/snapshot.rb +1 -1
  103. data/lib/rigor/effects/summary.rb +5 -4
  104. data/lib/rigor/environment/member_consistency.rb +10 -0
  105. data/lib/rigor/environment/rbs_loader.rb +19 -22
  106. data/lib/rigor/environment/reflection.rb +1 -1
  107. data/lib/rigor/environment/unreadable_signature.rb +21 -0
  108. data/lib/rigor/environment.rb +8 -8
  109. data/lib/rigor/flow_contribution/merger.rb +1 -0
  110. data/lib/rigor/hashing/xxh3.rb +1 -1
  111. data/lib/rigor/inference/acceptance.rb +23 -2
  112. data/lib/rigor/inference/alias_mutation_floor/site_collector.rb +5 -0
  113. data/lib/rigor/inference/alias_mutation_floor.rb +0 -5
  114. data/lib/rigor/inference/anonymous_meta_class.rb +2 -2
  115. data/lib/rigor/inference/block_call_timing.rb +6 -0
  116. data/lib/rigor/inference/budget_trace.rb +3 -2
  117. data/lib/rigor/inference/builtins/date_catalog.rb +3 -3
  118. data/lib/rigor/inference/builtins/method_catalog.rb +3 -3
  119. data/lib/rigor/inference/builtins/time_catalog.rb +3 -3
  120. data/lib/rigor/inference/call_ladder/literal_send.rb +98 -0
  121. data/lib/rigor/inference/call_ladder/overriding_def.rb +98 -0
  122. data/lib/rigor/inference/call_ladder/project_singleton.rb +362 -0
  123. data/lib/rigor/inference/call_ladder/refined.rb +212 -0
  124. data/lib/rigor/inference/call_ladder/top_level_def.rb +222 -0
  125. data/lib/rigor/inference/call_ladder/user_method.rb +247 -0
  126. data/lib/rigor/inference/call_ladder.rb +219 -0
  127. data/lib/rigor/inference/callee_write_census.rb +2 -2
  128. data/lib/rigor/inference/captured_locals.rb +2 -2
  129. data/lib/rigor/inference/clause_widening.rb +63 -1
  130. data/lib/rigor/inference/declaration_walk/context.rb +12 -12
  131. data/lib/rigor/inference/declaration_walk/rules.rb +750 -0
  132. data/lib/rigor/inference/declaration_walk/traversal.rb +9 -8
  133. data/lib/rigor/inference/declaration_walk.rb +4 -3
  134. data/lib/rigor/inference/def_node_resolver.rb +2 -2
  135. data/lib/rigor/inference/def_return_typer.rb +14 -6
  136. data/lib/rigor/inference/deferred_mutation.rb +120 -0
  137. data/lib/rigor/inference/define_method_block_self.rb +1 -1
  138. data/lib/rigor/inference/definer_resolution.rb +4 -4
  139. data/lib/rigor/inference/error_info.rb +8 -8
  140. data/lib/rigor/inference/expression_typer/composites.rb +348 -0
  141. data/lib/rigor/inference/expression_typer/per_element_assemblers.rb +233 -0
  142. data/lib/rigor/inference/expression_typer/writes.rb +218 -0
  143. data/lib/rigor/inference/expression_typer.rb +275 -1825
  144. data/lib/rigor/inference/external_ancestor_resolution.rb +2 -2
  145. data/lib/rigor/inference/fallback.rb +1 -0
  146. data/lib/rigor/inference/for_yield_slots.rb +126 -0
  147. data/lib/rigor/inference/genuine_send.rb +92 -0
  148. data/lib/rigor/inference/global_write_census.rb +2 -2
  149. data/lib/rigor/inference/hkt_body.rb +2 -0
  150. data/lib/rigor/inference/in_effect_refinements/walk.rb +2 -2
  151. data/lib/rigor/inference/index_write_widening.rb +4 -4
  152. data/lib/rigor/inference/indexed_narrowing.rb +1 -1
  153. data/lib/rigor/inference/intervening_ivar_reset.rb +46 -9
  154. data/lib/rigor/inference/ivar_writer_census.rb +1 -1
  155. data/lib/rigor/inference/loop_store_sites.rb +239 -0
  156. data/lib/rigor/inference/macro_block_self_type.rb +4 -3
  157. data/lib/rigor/inference/method_dispatcher/block_folding.rb +3 -2
  158. data/lib/rigor/inference/method_dispatcher/call_context.rb +84 -14
  159. data/lib/rigor/inference/method_dispatcher/composite_receiver.rb +144 -0
  160. data/lib/rigor/inference/method_dispatcher/constant_folding.rb +7 -5
  161. data/lib/rigor/inference/method_dispatcher/declared_constructor.rb +1 -1
  162. data/lib/rigor/inference/method_dispatcher/dependency_source.rb +90 -0
  163. data/lib/rigor/inference/method_dispatcher/discovered_method.rb +78 -0
  164. data/lib/rigor/inference/method_dispatcher/file_folding.rb +2 -2
  165. data/lib/rigor/inference/method_dispatcher/hkt_builtin_return.rb +40 -0
  166. data/lib/rigor/inference/method_dispatcher/iterator_dispatch.rb +1 -6
  167. data/lib/rigor/inference/method_dispatcher/literal_string_folding.rb +4 -2
  168. data/lib/rigor/inference/method_dispatcher/match_data_folding.rb +1 -1
  169. data/lib/rigor/inference/method_dispatcher/meta_introspection.rb +506 -0
  170. data/lib/rigor/inference/method_dispatcher/overload_selector.rb +2 -0
  171. data/lib/rigor/inference/method_dispatcher/plugin_contribution.rb +134 -0
  172. data/lib/rigor/inference/method_dispatcher/project_patched.rb +134 -0
  173. data/lib/rigor/inference/method_dispatcher/rbs_dispatch.rb +125 -43
  174. data/lib/rigor/inference/method_dispatcher/reduce_folding.rb +3 -4
  175. data/lib/rigor/inference/method_dispatcher/regexp_folding.rb +1 -1
  176. data/lib/rigor/inference/method_dispatcher/set_folding.rb +1 -1
  177. data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +19 -6
  178. data/lib/rigor/inference/method_dispatcher/singleton_folding.rb +3 -3
  179. data/lib/rigor/inference/method_dispatcher/singleton_mixin_dispatch.rb +7 -4
  180. data/lib/rigor/inference/method_dispatcher/static_refinement.rb +106 -0
  181. data/lib/rigor/inference/method_dispatcher/synthesized_stub.rb +41 -0
  182. data/lib/rigor/inference/method_dispatcher/synthetic_method_dispatch.rb +133 -0
  183. data/lib/rigor/inference/method_dispatcher/universal_object_dispatch.rb +2 -1
  184. data/lib/rigor/inference/method_dispatcher/user_class_fallback.rb +216 -0
  185. data/lib/rigor/inference/method_dispatcher.rb +175 -1361
  186. data/lib/rigor/inference/method_parameter_binder.rb +18 -18
  187. data/lib/rigor/inference/module_function_state.rb +5 -4
  188. data/lib/rigor/inference/mutation_widening.rb +20 -7
  189. data/lib/rigor/inference/narrowing/case_literals.rb +58 -0
  190. data/lib/rigor/inference/narrowing/class_dispatch.rb +302 -0
  191. data/lib/rigor/inference/narrowing/complements.rb +322 -0
  192. data/lib/rigor/inference/narrowing/presence_predicates.rb +205 -0
  193. data/lib/rigor/inference/narrowing/regex_match.rb +499 -0
  194. data/lib/rigor/inference/narrowing.rb +86 -1269
  195. data/lib/rigor/inference/object_mixins.rb +2 -2
  196. data/lib/rigor/inference/opaque_mutation.rb +214 -0
  197. data/lib/rigor/inference/optimistic_origin.rb +52 -14
  198. data/lib/rigor/inference/parameter_inference_collector.rb +1 -1
  199. data/lib/rigor/inference/pre_eval_constants.rb +11 -9
  200. data/lib/rigor/inference/precision_scanner.rb +27 -2
  201. data/lib/rigor/inference/project_patched_methods.rb +3 -3
  202. data/lib/rigor/inference/range_constant.rb +3 -3
  203. data/lib/rigor/inference/rbs_type_translator.rb +2 -2
  204. data/lib/rigor/inference/refine_self.rb +8 -7
  205. data/lib/rigor/inference/refined_dispatch.rb +2 -2
  206. data/lib/rigor/inference/return_barrier.rb +24 -9
  207. data/lib/rigor/inference/scope_indexer/alias_def_nodes.rb +311 -0
  208. data/lib/rigor/inference/scope_indexer/census_scope.rb +47 -0
  209. data/lib/rigor/inference/scope_indexer/certainty.rb +2 -2
  210. data/lib/rigor/inference/scope_indexer/class_cvar_census.rb +282 -0
  211. data/lib/rigor/inference/scope_indexer/class_cvars_collector.rb +12 -5
  212. data/lib/rigor/inference/scope_indexer/class_declarations.rb +228 -0
  213. data/lib/rigor/inference/scope_indexer/class_ivar_index.rb +2028 -0
  214. data/lib/rigor/inference/scope_indexer/constant_ivar_value.rb +4 -3
  215. data/lib/rigor/inference/scope_indexer/constant_tables.rb +844 -0
  216. data/lib/rigor/inference/scope_indexer/cvar_hierarchy.rb +159 -0
  217. data/lib/rigor/inference/scope_indexer/declaration_artifacts.rb +219 -0
  218. data/lib/rigor/inference/scope_indexer/declaration_signature.rb +212 -0
  219. data/lib/rigor/inference/scope_indexer/def_nestings_collector.rb +2 -2
  220. data/lib/rigor/inference/scope_indexer/factory_call_resolver.rb +53 -0
  221. data/lib/rigor/inference/scope_indexer/literal_receiver_mutations.rb +266 -0
  222. data/lib/rigor/inference/scope_indexer/member_layouts_collector.rb +8 -7
  223. data/lib/rigor/inference/scope_indexer/mixin_accumulator.rb +1 -1
  224. data/lib/rigor/inference/scope_indexer/mixin_effects.rb +470 -0
  225. data/lib/rigor/inference/scope_indexer/mixin_tables.rb +388 -0
  226. data/lib/rigor/inference/scope_indexer/mutated_carrier_widening.rb +163 -0
  227. data/lib/rigor/inference/scope_indexer/mutated_element_census.rb +211 -0
  228. data/lib/rigor/inference/scope_indexer/node_propagation.rb +520 -0
  229. data/lib/rigor/inference/scope_indexer/program_globals.rb +154 -0
  230. data/lib/rigor/inference/scope_indexer/published_constant_cvars.rb +146 -0
  231. data/lib/rigor/inference/scope_indexer/published_constant_ivars.rb +181 -0
  232. data/lib/rigor/inference/scope_indexer/shared_walk_tables.rb +823 -0
  233. data/lib/rigor/inference/scope_indexer/singleton_class_sources.rb +85 -0
  234. data/lib/rigor/inference/scope_indexer/superclasses_collector.rb +5 -5
  235. data/lib/rigor/inference/scope_indexer.rb +2657 -9558
  236. data/lib/rigor/inference/self_call_ivar_writes.rb +22 -3
  237. data/lib/rigor/inference/set_mutation.rb +2 -2
  238. data/lib/rigor/inference/singleton_hook_definers.rb +185 -0
  239. data/lib/rigor/inference/statement_evaluator/def_arguments_and_assertions.rb +365 -0
  240. data/lib/rigor/inference/statement_evaluator/pattern_bindings.rb +581 -0
  241. data/lib/rigor/inference/statement_evaluator.rb +201 -1008
  242. data/lib/rigor/inference/synthetic_method_scanner.rb +0 -3
  243. data/lib/rigor/language_server/completion_provider.rb +8 -8
  244. data/lib/rigor/language_server/diagnostic_publisher.rb +6 -7
  245. data/lib/rigor/language_server/document_symbol_provider.rb +4 -6
  246. data/lib/rigor/language_server/folding_range_provider.rb +3 -3
  247. data/lib/rigor/language_server/hover_provider.rb +2 -2
  248. data/lib/rigor/language_server/loop.rb +2 -2
  249. data/lib/rigor/language_server/server.rb +3 -2
  250. data/lib/rigor/language_server/signature_help_provider.rb +7 -9
  251. data/lib/rigor/lens/document.rb +10 -1
  252. data/lib/rigor/lens/file_reader.rb +2 -1
  253. data/lib/rigor/mcp/loop.rb +48 -6
  254. data/lib/rigor/mcp/server.rb +248 -23
  255. data/lib/rigor/mcp/skill_catalog.rb +157 -0
  256. data/lib/rigor/plugin/base.rb +22 -4
  257. data/lib/rigor/plugin/effect_attribution.rb +1 -1
  258. data/lib/rigor/plugin/inflector.rb +2 -2
  259. data/lib/rigor/plugin/io_boundary.rb +1 -1
  260. data/lib/rigor/plugin/loader.rb +4 -4
  261. data/lib/rigor/plugin/macro/heredoc_template.rb +4 -3
  262. data/lib/rigor/plugin/optimistic_return.rb +20 -0
  263. data/lib/rigor/plugin/registry.rb +2 -2
  264. data/lib/rigor/plugin/template_unit.rb +4 -2
  265. data/lib/rigor/plugin/trust_policy.rb +2 -1
  266. data/lib/rigor/plugin.rb +1 -1
  267. data/lib/rigor/protection/mutator.rb +8 -9
  268. data/lib/rigor/rbs_extended/reporter.rb +2 -2
  269. data/lib/rigor/rbs_extended.rb +2 -2
  270. data/lib/rigor/reflection/constant_ancestors.rb +1 -1
  271. data/lib/rigor/reflection/project_method.rb +2 -2
  272. data/lib/rigor/reflection.rb +4 -4
  273. data/lib/rigor/scope/discovery_index.rb +15 -10
  274. data/lib/rigor/scope/resolution_chain.rb +29 -6
  275. data/lib/rigor/scope.rb +89 -32
  276. data/lib/rigor/sig_gen/generator.rb +5 -4
  277. data/lib/rigor/sig_gen/renderer.rb +3 -3
  278. data/lib/rigor/sig_gen/writer.rb +8 -6
  279. data/lib/rigor/source/parameter_envelope.rb +1 -1
  280. data/lib/rigor/triage/catalogue.rb +4 -4
  281. data/lib/rigor/type/combinator.rb +2 -2
  282. data/lib/rigor/type/data_instance.rb +2 -2
  283. data/lib/rigor/type/struct_instance.rb +3 -3
  284. data/lib/rigor/type_node/generic.rb +2 -1
  285. data/lib/rigor/type_of_memo.rb +2 -1
  286. data/lib/rigor/typing_state.rb +3 -2
  287. data/lib/rigor/version.rb +1 -1
  288. data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/analyzer.rb +2 -2
  289. data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/channel_discoverer.rb +1 -1
  290. data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer/mailer_discoverer.rb +4 -4
  291. data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer.rb +1 -1
  292. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/controller_discoverer.rb +4 -3
  293. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/effects.rb +7 -5
  294. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/erb_compiler.rb +4 -2
  295. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/render_locals.rb +1 -1
  296. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/view_assigns.rb +3 -2
  297. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack.rb +7 -7
  298. data/plugins/rigor-activejob/lib/rigor/plugin/activejob/job_discoverer.rb +1 -1
  299. data/plugins/rigor-activejob/lib/rigor/plugin/activejob.rb +2 -2
  300. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_discoverer.rb +9 -8
  301. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_index.rb +3 -2
  302. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_parser.rb +15 -7
  303. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_table.rb +10 -3
  304. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/structure_sql_parser.rb +12 -1
  305. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord.rb +20 -5
  306. data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage/attachment_discoverer.rb +1 -1
  307. data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage.rb +3 -2
  308. data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext/effects.rb +1 -1
  309. data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext.rb +8 -7
  310. data/plugins/rigor-dry-schema/lib/rigor/plugin/dry_schema.rb +1 -1
  311. data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types/alias_scanner.rb +1 -1
  312. data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types.rb +6 -7
  313. data/plugins/rigor-factorybot/lib/rigor/plugin/factorybot/factory_discoverer.rb +3 -2
  314. data/plugins/rigor-graphql/lib/rigor/plugin/graphql/type_scanner.rb +4 -3
  315. data/plugins/rigor-hanami/lib/rigor/plugin/hanami.rb +4 -2
  316. data/plugins/rigor-minitest/lib/rigor/plugin/minitest.rb +1 -1
  317. data/plugins/rigor-pundit/lib/rigor/plugin/pundit.rb +1 -1
  318. data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n/analyzer.rb +5 -3
  319. data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n.rb +1 -1
  320. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/devise_routes.rb +4 -5
  321. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/doorkeeper_routes.rb +2 -2
  322. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_discoverer.rb +5 -4
  323. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_table.rb +3 -2
  324. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/routes_parser.rb +30 -31
  325. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes.rb +13 -15
  326. data/plugins/rigor-rbnacl/lib/rigor/plugin/rbnacl.rb +1 -1
  327. data/plugins/rigor-rspec/lib/rigor/plugin/rspec/let_scope_index.rb +4 -3
  328. data/plugins/rigor-rspec/lib/rigor/plugin/rspec/matcher_analyzer.rb +16 -13
  329. data/plugins/rigor-rspec/lib/rigor/plugin/rspec/scope_walker.rb +3 -2
  330. data/plugins/rigor-shoulda-matchers/lib/rigor/plugin/shoulda_matchers/analyzer.rb +6 -6
  331. data/plugins/rigor-sidekiq/lib/rigor/plugin/sidekiq/analyzer.rb +3 -3
  332. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/assertion_recognizer.rb +2 -2
  333. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog.rb +3 -2
  334. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog_walker.rb +6 -5
  335. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sig_parser.rb +2 -2
  336. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sigil_detector.rb +4 -5
  337. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/type_translator.rb +1 -1
  338. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet.rb +3 -4
  339. data/sig/rigor/analysis/check_rules/suppression.rbs +9 -0
  340. data/sig/rigor/analysis/dependency_recorder.rbs +9 -0
  341. data/sig/rigor/inference.rbs +275 -11
  342. data/sig/rigor/plugin/base.rbs +14 -5
  343. data/sig/rigor/plugin/optimistic_return.rbs +16 -0
  344. data/sig/rigor/scope.rbs +7 -1
  345. data/sig/rigor/source.rbs +4 -0
  346. data/skills/rigor-mcp-setup/SKILL.md +20 -6
  347. data/skills/rigor-plugin-review/SKILL.md +3 -3
  348. data/skills/rigor-type-oracle/references/01-oracle-commands.md +1 -1
  349. metadata +90 -3
@@ -122,7 +122,6 @@ module Rigor
122
122
  return [] if plugin_registry.nil? || plugin_registry.empty?
123
123
 
124
124
  plugin_registry.plugins.flat_map do |plugin|
125
- # rigor:disable undefined-method
126
125
  plugin.manifest.heredoc_templates.map do |template|
127
126
  [plugin.manifest.id, template]
128
127
  end
@@ -135,7 +134,6 @@ module Rigor
135
134
  return [] if plugin_registry.nil? || plugin_registry.empty?
136
135
 
137
136
  plugin_registry.plugins.flat_map do |plugin|
138
- # rigor:disable undefined-method
139
137
  plugin.manifest.trait_registries.map do |registry|
140
138
  [plugin.manifest.id, registry]
141
139
  end
@@ -148,7 +146,6 @@ module Rigor
148
146
  return [] if plugin_registry.nil? || plugin_registry.empty?
149
147
 
150
148
  plugin_registry.plugins.flat_map do |plugin|
151
- # rigor:disable undefined-method
152
149
  plugin.manifest.nested_class_templates.map do |template|
153
150
  [plugin.manifest.id, template]
154
151
  end
@@ -49,7 +49,7 @@ module Rigor
49
49
  # "no completions available," distinct from `[]` which
50
50
  # means "we tried and got nothing".
51
51
  def provide(uri:, line:, character:, trigger_character: nil)
52
- _ = trigger_character # Trigger info logged-not-routed in v1.
52
+ _ = trigger_character # Trigger info accepted but not routed.
53
53
  path, entry = buffer_for(uri)
54
54
  return nil if entry.nil?
55
55
 
@@ -211,8 +211,8 @@ module Rigor
211
211
 
212
212
  # Slice B2 — `Foo::|` constant-path completion. The cursor sits on a `ConstantPathNode` whose `parent`
213
213
  # resolves to a class / module FQN; we enumerate every known class whose name is an immediate child of
214
- # that parent. Top-level constants (`::Foo`) and parent-less paths are not yet supported (queued for
215
- # slice 6 follow-up).
214
+ # that parent. A parent-less path (`::|`, completing a top-level constant) is not supported and yields
215
+ # nil; a leading `::` on the parent (`::Foo::|`) is ignored.
216
216
  def constant_path_completion_for(const_path_node)
217
217
  parent_fqn = parent_fqn_of(const_path_node)
218
218
  return nil if parent_fqn.nil?
@@ -226,7 +226,7 @@ module Rigor
226
226
 
227
227
  def parent_fqn_of(const_path_node)
228
228
  # ConstantPathNode#parent is the LHS of the `::`. For `Foo::Bar` it's the ConstantReadNode for `Foo`;
229
- # for `Foo::Bar::Baz` it's a ConstantPathNode. We render either to the dotted FQN string.
229
+ # for `Foo::Bar::Baz` it's a ConstantPathNode. We render either to the `::`-joined FQN string.
230
230
  parent = const_path_node.parent
231
231
  return nil if parent.nil?
232
232
 
@@ -253,8 +253,8 @@ module Rigor
253
253
  return [] if loader.nil?
254
254
 
255
255
  names = loader.send(:known_class_names_set)
256
- # RBS canonical names carry a leading `::` (so the table holds `::Process::Status` etc.). Match
257
- # against both forms so the prefix walk works regardless of which form the caller passes.
256
+ # RBS canonical names carry a leading `::` (so the table holds `::Process::Status` etc.), hence the
257
+ # `::`-prefixed match key.
258
258
  prefix = "::#{parent_fqn}::"
259
259
  names.filter_map do |fqn|
260
260
  next nil unless fqn.start_with?(prefix)
@@ -382,8 +382,8 @@ module Rigor
382
382
  detail: detail,
383
383
  insertText: label,
384
384
  filterText: label,
385
- # Inherited methods rank below own-class methods; the `defs.first.implemented_in` carries the
386
- # declaring class. Inheritance-distance ranking is queued (design doc § "sortText").
385
+ # Every method gets the same `1_` rank; owner-proximity ranking (own-class before inherited, using
386
+ # `defs.first.implemented_in`) described in the design doc § "sortText" is not implemented.
387
387
  sortText: "1_#{label}"
388
388
  }
389
389
  end
@@ -31,20 +31,20 @@ module Rigor
31
31
  hint: 4
32
32
  }.freeze
33
33
 
34
+ # The single Debouncer key every save round shares (#246). Per-URI keys would let two saves start two
35
+ # concurrent rounds; one key means a burst collapses into the last one.
36
+ PROJECT_ROUND_KEY = :__rigor_project_round__
37
+
34
38
  # @param debouncer —
35
39
  # when present, `publish_for` schedules its work through
36
40
  # the debouncer (cancels prior pending task for the same
37
41
  # URI, fires after `debounce_seconds` quiet-time). Nil
38
- # keeps the slice 4-7 synchronous behaviour — primarily
42
+ # keeps the synchronous behaviour — primarily
39
43
  # useful for specs.
40
44
  # @param debounce_seconds — quiet-time before the
41
45
  # debounced publish fires. 0 with a debouncer means
42
46
  # "schedule on next-tick" (still async); without a
43
47
  # debouncer the value is unused.
44
- # The single Debouncer key every save round shares (#246). Per-URI keys would let two saves start two
45
- # concurrent rounds; one key means a burst collapses into the last one.
46
- PROJECT_ROUND_KEY = :__rigor_project_round__
47
-
48
48
  def initialize(writer:, buffer_table:, project_context:,
49
49
  debouncer: nil, debounce_seconds: 0.2)
50
50
  @writer = writer
@@ -348,8 +348,7 @@ module Rigor
348
348
  return nil if diagnostic.path != buffer_path
349
349
 
350
350
  # Rigor uses 1-based line + 1-based byte column; LSP uses 0-based line + 0-based UTF-16 code unit.
351
- # UTF-16 conversion is queued (design doc § "Open questions"); v1 emits byte columns which are
352
- # correct for ASCII source.
351
+ # No UTF-16 conversion is done here; byte columns are emitted, which are correct for ASCII source.
353
352
  line = (diagnostic.line - 1).clamp(0, Float::INFINITY).to_i
354
353
  character = (diagnostic.column - 1).clamp(0, Float::INFINITY).to_i
355
354
 
@@ -30,10 +30,9 @@ module Rigor
30
30
  @project_context = project_context
31
31
  end
32
32
 
33
- # @return LSP document symbols for the
34
- # buffer at `uri`. Returns nil when the URI isn't open or
35
- # doesn't parse cleanly enough to surface symbols — LSP
36
- # clients fall back to no-outline in that case.
33
+ # @return LSP document symbols for the buffer at `uri`. Returns nil when the URI isn't open (or is
34
+ # desynchronised) — LSP clients fall back to no-outline in that case. A buffer with parse errors still
35
+ # yields whatever outline Prism recovered.
37
36
  def provide(uri)
38
37
  path, entry = buffer_for(uri)
39
38
  return nil if entry.nil?
@@ -125,8 +124,7 @@ module Rigor
125
124
  end
126
125
 
127
126
  # LSP `Range` is 0-based start + end with `character` in UTF-16 code units. This implementation emits
128
- # byte columns (correct for ASCII source); UTF-16 conversion stays queued per design doc § "Open
129
- # questions".
127
+ # byte columns (correct for ASCII source); UTF-16 conversion is not implemented here.
130
128
  def range_from(location)
131
129
  {
132
130
  start: { line: location.start_line - 1, character: location.start_column },
@@ -10,7 +10,7 @@ module Rigor
10
10
  module LanguageServer
11
11
  # Answers `textDocument/foldingRange` requests. Walks the Prism AST and emits one `FoldingRange` per
12
12
  # foldable construct: `class` / `module` / `def` / `singleton class << self` / block (`do…end` or `{…}`).
13
- # Skips single-line constructs (start_line == end_line) since there's nothing to fold.
13
+ # Skips constructs with no body line to hide (single-line, or opener directly followed by `end`).
14
14
  #
15
15
  # Ranges are LSP 0-based. `startLine` is the line containing the opening keyword (`class`, `def`); `endLine`
16
16
  # is the last line OF the body — one line before the `end` keyword — so collapsed view shows the opener
@@ -55,8 +55,8 @@ module Rigor
55
55
  loc = node.location
56
56
  start_line = loc.start_line - 1
57
57
  # `end_line` includes the line of the `end` keyword. Folding should hide the body and leave both the
58
- # opener AND the `end` keyword visible — so endLine is one line before `end`. When the body is a single
59
- # line, that makes start == end (one-line fold), which most editors skip; we filter those out.
58
+ # opener AND the `end` keyword visible — so endLine is one line before `end`. When there is no body line
59
+ # between opener and `end`, that makes endLine <= startLine, so we filter those out.
60
60
  end_line = loc.end_line - 2
61
61
  return if end_line <= start_line
62
62
 
@@ -18,8 +18,8 @@ module Rigor
18
18
  #
19
19
  # Per LSP spec § "Position":
20
20
  # - `line` and `character` are 0-based.
21
- # - `character` counts UTF-16 code units; v1 emits byte counts for ASCII source (UTF-16 conversion is
22
- # queued, see design doc § "Open questions").
21
+ # - `character` counts UTF-16 code units; this provider reads it as a byte column, which is correct for
22
+ # ASCII source (no UTF-16 conversion is done here).
23
23
  class HoverProvider
24
24
  include BufferResolution
25
25
 
@@ -17,8 +17,8 @@ module Rigor
17
17
  # - Notification (`id` absent) → NEVER gets a response. The dispatcher's return value is discarded.
18
18
  #
19
19
  # JSON parse errors at the framing boundary surface as an LSP `ParseError` (-32700) response with
20
- # `id: null` per JSON-RPC spec § 5.1; the loop continues so a corrupt frame doesn't poison the rest of the
21
- # session.
20
+ # `id: null` per JSON-RPC spec § 5.1. The parse happens inside the reader's own read loop, so the exception
21
+ # unwinds it and `#run` returns after writing the error; the loop does not resume reading.
22
22
  class Loop
23
23
  def initialize(reader:, writer:, server:)
24
24
  @reader = reader
@@ -8,8 +8,9 @@ module Rigor
8
8
  module LanguageServer
9
9
  # LSP server lifecycle state machine + JSON-RPC method dispatcher. State machine: `:uninitialized` →
10
10
  # `:initialized` → `:shutdown` → `:exited`. {#dispatch} routes (method, params) to the matching handler and
11
- # returns the response payload (`nil` for notifications); out-of-state requests return `InvalidRequest`
12
- # (-32002) / `MethodNotFound` (-32601). Full v1 capability surface (document sync, publishDiagnostics,
11
+ # returns the response payload (`nil` for notifications); out-of-state requests return
12
+ # `ServerNotInitialized` (-32002) / `InvalidRequest` (-32600), and an unknown or unwired method returns
13
+ # `MethodNotFound` (-32601). Full v1 capability surface (document sync, publishDiagnostics,
13
14
  # hover, completion, sig-help, folding, selection, and watched-file invalidation) is implemented.
14
15
  class Server # rubocop:disable Metrics/ClassLength
15
16
  # JSON-RPC error codes per LSP spec § "Response Message".
@@ -23,16 +23,14 @@ module Rigor
23
23
  # Answers `textDocument/signatureHelp` requests. When the user types `(` inside a method call
24
24
  # (`obj.foo(|`) editors fire `signatureHelp` to show the method's parameter signature inline. The provider
25
25
  # parses the buffer, locates the enclosing `CallNode`, infers the receiver's type, and returns the
26
- # method's first overload as a `SignatureInformation`.
26
+ # method's overloads as `SignatureInformation` entries (each carries the RBS comment as `documentation`
27
+ # when there is one).
27
28
  #
28
- # Slice C1 ships:
29
29
  # - Sentinel patching for `obj.foo(|` so Prism's parse succeeds (mirrors `CompletionProvider`'s slice B4
30
30
  # pattern).
31
- # - First-overload signature only.
32
- # - Active parameter = comma count before cursor.
33
- #
34
- # Multi-overload presentation + `documentation` field + active-parameter override per overload land in
35
- # follow-up slices (queued in the design doc § "Out of scope for v2").
31
+ # - `activeSignature` is always the first overload; `activeParameter` is the comma count before the cursor
32
+ # (the same index for every overload).
33
+ # - Calls without an explicit receiver (implicit `self`) get no signature help.
36
34
  class SignatureHelpProvider
37
35
  include BufferResolution
38
36
 
@@ -131,8 +129,8 @@ module Rigor
131
129
  end
132
130
  {
133
131
  signatures: signatures,
134
- # `activeSignature` is the index editors highlight by default. Slice C2 picks the first overload
135
- # uniformly; a future slice could choose the overload that best matches the current argument shape.
132
+ # `activeSignature` is the index editors highlight by default. It is the first overload uniformly;
133
+ # the argument shape is not matched against the overloads.
136
134
  activeSignature: 0,
137
135
  activeParameter: active_param
138
136
  }
@@ -4,6 +4,7 @@ require "json"
4
4
 
5
5
  require_relative "../version"
6
6
  require_relative "../cache/engine_source"
7
+ require_relative "../cache/rbs_descriptor"
7
8
  require_relative "../analysis/run_cache_key"
8
9
  require_relative "../rooted_glob"
9
10
 
@@ -62,11 +63,19 @@ module Rigor
62
63
 
63
64
  def signature_digest
64
65
  listing = signature_roots.flat_map { |root| RootedGlob.glob(root, "**/*.rbs") }.sort.map do |path|
65
- "#{relative(path)}\t#{Lens.digest(File.binread(path))}\n"
66
+ "#{relative(path)}\t#{signature_file_digest(path)}\n"
66
67
  end
67
68
  Lens.digest(listing.join)
68
69
  end
69
70
 
71
+ # Issue #3469 — a file the RBS loader skips as unreadable (a symlink loop, a dangling symlink, a directory
72
+ # named `*.rbs`, `chmod 000`) folds in the cache's `unreadable` marker instead of raising.
73
+ def signature_file_digest(path)
74
+ Lens.digest(File.binread(path))
75
+ rescue *Environment::UnreadableSignature::ERRORS
76
+ Cache::RbsDescriptor::UNREADABLE_DIGEST
77
+ end
78
+
70
79
  def lockfiles
71
80
  Analysis::RunCacheKey.resolved_lockfile_paths(@configuration).compact.filter_map do |path|
72
81
  absolute = File.expand_path(path.to_s)
@@ -23,7 +23,8 @@ module Rigor
23
23
  # walk cannot place (under an `if`, a `begin`, a block) leaves that default unknown.
24
24
  # A `detached` body stands for code that is not the class body (a block, a method body, a superclass
25
25
  # expression, an omitted class): its toggles and named calls stay local and change no site.
26
- # `kind` is :module, :class or :singleton. `module_function` is :off, :on (a bare `module_function` written
26
+ # `kind` is :module, :class, :singleton, :builder (a `Data.define` / `Struct.new` block) or :detached.
27
+ # `module_function` is :off, :on (a bare `module_function` written
27
28
  # directly in a module body covers the later direct defs) or :unknown (the reading Ruby gives and the one
28
29
  # `check`'s tables give could differ, so the later defs are omissions).
29
30
  # `lexical` is the named part of the body's Ruby cref chain, which a builder block does not extend (Ruby
@@ -6,11 +6,18 @@ module Rigor
6
6
  module MCP
7
7
  # Reads newline-delimited JSON-RPC 2.0 messages from `input`, dispatches each to `server`, and writes responses to
8
8
  # `output`. Runs until input reaches EOF (the client closes the connection).
9
+ #
10
+ # A failure on one request never ends the loop (#3426, #3435): a response the server raises on is answered
11
+ # `-32603` with that request's id, and a response JSON refuses to encode is replaced by the same `-32603`, or by
12
+ # one with a null id when the request's id is not a valid JSON-RPC id. Every later line is still read and answered.
9
13
  class Loop
10
- def initialize(input:, output:, server:)
14
+ PARSE_ERROR = -32_700
15
+
16
+ def initialize(input:, output:, server:, err: $stderr)
11
17
  @input = input
12
18
  @output = output
13
19
  @server = server
20
+ @err = err
14
21
  end
15
22
 
16
23
  def run
@@ -21,21 +28,56 @@ module Rigor
21
28
  begin
22
29
  request = JSON.parse(line)
23
30
  rescue JSON::ParserError => e
24
- write_response({ "jsonrpc" => "2.0", "id" => nil,
25
- "error" => { "code" => -32_700, "message" => "Parse error: #{e.message}" } })
31
+ write_response(error_body(nil, PARSE_ERROR, "Parse error: #{scrubbed(e.message)}"))
26
32
  next
27
33
  end
28
34
 
29
- response = @server.handle(request)
30
- write_response(response) if response
35
+ answer(request)
31
36
  end
32
37
  end
33
38
 
34
39
  private
35
40
 
36
- def write_response(response)
41
+ # A notification (no id) is answered by nothing, even when it fails; only its failure is logged.
42
+ def answer(request)
43
+ id = request.is_a?(Hash) ? request["id"] : nil
44
+ response = handle_request(request, id)
45
+ write_response(response, id) if response
46
+ end
47
+
48
+ def handle_request(request, id)
49
+ @server.handle(request)
50
+ rescue StandardError => e
51
+ log(e)
52
+ error_body(id, Server::INTERNAL_ERROR, "Internal error") unless id.nil?
53
+ end
54
+
55
+ # Writes one response line. JSON refuses a non-finite number or invalid UTF-8, so a response that does not
56
+ # encode is replaced by a `-32603` for its id, or for a null id when the id is itself not a valid JSON-RPC id.
57
+ def write_response(response, id = nil)
37
58
  @output.puts(JSON.generate(response))
38
59
  @output.flush
60
+ rescue JSON::GeneratorError => e
61
+ log(e)
62
+ fallback = error_body(Server.valid_id?(id) ? id : nil, Server::INTERNAL_ERROR, "Internal error")
63
+ @output.puts(JSON.generate(fallback))
64
+ @output.flush
65
+ end
66
+
67
+ def error_body(id, code, message)
68
+ { "jsonrpc" => "2.0", "id" => id, "error" => { "code" => code, "message" => message } }
69
+ end
70
+
71
+ # The parser's message can echo the line's bytes, which need not be valid UTF-8. Scrubbing keeps it encodable
72
+ # without echoing the raw bytes.
73
+ def scrubbed(message)
74
+ message.dup.force_encoding(Encoding::UTF_8).scrub
75
+ end
76
+
77
+ # Logs in the shape `Server#tools_call` uses for an internal error: the class, the message, and the first frames.
78
+ def log(error)
79
+ @err.puts("rigor mcp: #{error.class}: #{error.message}")
80
+ @err.puts(error.backtrace.first(5).join("\n")) if error.backtrace
39
81
  end
40
82
  end
41
83
  end