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
@@ -14,15 +14,16 @@ module Rigor
14
14
  # The supported matchers are the lowest-false-positive floor of the RSpec matcher DSL:
15
15
  #
16
16
  # - `be_a(T)` / `be_kind_of(T)` — `x is_a?(T)` style class membership; narrows `x` to `T`.
17
- # - `be_instance_of(T)` — exact-class match; narrows `x` to `T` (the engine currently treats
18
- # Nominal[T] uniformly, so the distinction with `be_a` is observed at the carrier level but not the
19
- # runtime).
17
+ # - `be_instance_of(T)` / `be_an_instance_of(T)` — exact-class match; narrows `x` to `T` (the engine
18
+ # currently treats Nominal[T] uniformly, so the distinction with `be_a` is observed at the carrier
19
+ # level but not the runtime).
20
20
  # - `be_nil` — narrows `x` to `Constant<nil>`.
21
21
  # - `eq(LITERAL)` / `eql(LITERAL)` for a literal-value argument — meets `x` with `Constant<literal>`
22
22
  # (see "Equality is the local's own method" below).
23
+ # - `match(/regex/)` — a meet with the local's members (see `regex_match_type`).
23
24
  #
24
25
  # The matchers below this floor (`be_truthy` / `be_falsey` / `be_within` / `be > / < / >=` /
25
- # `include` / `start_with` / `match(regex)` / `raise_error` / receive-style mocks) require either
26
+ # `include` / `start_with` / `raise_error` / receive-style mocks) require either
26
27
  # edge-aware fragments (`truthy_facts` / `falsey_facts` rather than `post_return_facts`) or
27
28
  # diagnostic-only enforcement; both are queued for follow-up slices.
28
29
  #
@@ -293,15 +294,17 @@ module Rigor
293
294
 
294
295
  # --- `match(/regex/)` (#2033) ---
295
296
  #
296
- # RSpec's `match` passes when `expected === actual`, when `actual == expected`, or when `actual` responds to
297
- # `match` and `actual.match(expected)` is truthy. `Regexp#===` matches a Symbol by its name, so a Symbol
298
- # passes too, and keeps being a Symbol. The positive fact is therefore a meet with the local's members, as
299
- # `eq`'s is: a String or Symbol member is kept as it is, and a member of a core class that has no `match` or
300
- # `to_str` and whose `==` never equals a Regexp (`nil`, `true`, `false`, the numerics) is dropped, unless the
301
- # project defines one of those methods on it or a core ancestor. An `Object`, `BasicObject`, `Kernel` or
302
- # `Comparable` member reads `String | Symbol` ({#module_match_member}); any other module means no fact. Any other member (a user class, `Dynamic`) may pass, and
303
- # the analyzer emits no fact; so does a subject none of whose members can pass (a `nil` local stays `nil`). The negative form emits none either: a String that does not match passes
304
- # `not_to match`, so nothing leaves the local.
297
+ # RSpec's `match` passes when `expected === actual`, when `actual == expected`, or when `actual` responds
298
+ # to `match` and `actual.match(expected)` is truthy. `Regexp#===` matches a Symbol by its name, so a
299
+ # Symbol passes too, and keeps being a Symbol. The positive fact is therefore a meet with the local's
300
+ # members, as `eq`'s is: a String or Symbol member is kept as it is, and a member of a core class that
301
+ # has no `match` or `to_str` and whose `==` never equals a Regexp (`nil`, `true`, `false`, the numerics)
302
+ # is dropped, unless the project defines one of those methods on it or a core ancestor. An `Object`,
303
+ # `BasicObject`, `Kernel` or `Comparable` member reads `String | Symbol` ({#module_match_member}); any
304
+ # other module means no fact. Any other member (a user class, `Dynamic`) may pass, and the analyzer
305
+ # emits no fact; so does a subject none of whose members can pass (a `nil` local stays `nil`). The
306
+ # negative form emits none either: a String that does not match passes `not_to match`, so nothing
307
+ # leaves the local.
305
308
  REGEX_MATCH_KEPT_CLASSES = %w[String Symbol].freeze
306
309
  REGEX_MATCH_METHODS = %i[match to_str].freeze
307
310
  Ractor.make_shareable(REGEX_MATCH_KEPT_CLASSES)
@@ -12,8 +12,9 @@ module Rigor
12
12
  # `RSpec.describe`), a `Scope` value with the `let` and `subject` declarations recorded inside that
13
13
  # scope.
14
14
  #
15
- # Scope hierarchy is preserved: each `Scope` carries a list of its `nested_scopes`. The analyzer uses
16
- # the hierarchy to detect cross-scope shadowing.
15
+ # Scope hierarchy is preserved: each `Scope` carries a list of its `nested_scopes`. The analyzer visits
16
+ # every scope in the tree but checks each one's declarations on their own; it does not compare across
17
+ # scopes.
17
18
  #
18
19
  # Recognised scope methods (when called without a receiver, or with `RSpec` as the receiver):
19
20
  #
@@ -5,13 +5,13 @@ require "prism"
5
5
  module Rigor
6
6
  module Plugin
7
7
  class ShouldaMatchers < Rigor::Plugin::Base
8
- # Walks every `RSpec.describe <ModelConst> do ... end` / `describe <ModelConst> do ... end` block and
9
- # validates the shoulda-matchers calls inside its body (any depth of nested `describe` / `context`)
10
- # against the `:model_index` published by `rigor-activerecord`.
8
+ # Validates the shoulda-matchers calls inside an `RSpec.describe <ModelConst> do ... end` /
9
+ # `describe <ModelConst> do ... end` block (any depth of nested `describe` / `context`) against the
10
+ # `:model_index` published by `rigor-activerecord`.
11
11
  #
12
- # The "anchor" for cross-checking is the OUTERMOST describe block whose argument is a constant —
13
- # that constant names the model being specced. Nested `describe ".some_method"` (String / Symbol
14
- # args) does NOT change the anchor.
12
+ # The "anchor" for cross-checking is the INNERMOST enclosing describe block whose argument is a
13
+ # constant — that constant names the model being specced. Nested `describe ".some_method"` (String /
14
+ # Symbol args) does NOT change the anchor; a nested describe on another constant does.
15
15
  #
16
16
  # ## Recognised matcher calls (v0.1.0)
17
17
  #
@@ -5,9 +5,9 @@ require "prism"
5
5
  module Rigor
6
6
  module Plugin
7
7
  class Sidekiq < Rigor::Plugin::Base
8
- # Walks a parsed file's AST looking for `<WorkerClass>.perform_async(...)` / `.perform_inline(...)` /
9
- # `.perform_in(time, ...)` / `.perform_at(time, ...)` calls and validates each against the
10
- # {WorkerIndex}.
8
+ # Validates a `<WorkerClass>.perform_async(...)` / `.perform_inline(...)` / `.perform_in(time, ...)` /
9
+ # `.perform_at(time, ...)` call against the {WorkerIndex}. The engine owns the walk (ADR-37); this sees
10
+ # one call node at a time.
11
11
  #
12
12
  # Argument-shape rules:
13
13
  #
@@ -47,8 +47,8 @@ module Rigor
47
47
  # static return type is `Constant[nil]`.
48
48
  module AssertionRecognizer
49
49
  # Method names this recogniser claims as Sorbet assertions. The plugin checks call sites against
50
- # this set before any catalog lookup so a `T.let` call inside an analysed file always resolves
51
- # through this module.
50
+ # this set before any catalog lookup so a `T.let` call inside an enforced file (see the plugin's
51
+ # sigil gate) resolves through this module.
52
52
  SORBET_ASSERTIONS = %i[let cast must must_because unsafe reveal_type assert_type! bind].freeze
53
53
 
54
54
  module_function
@@ -177,8 +177,9 @@ module Rigor
177
177
  # Issue #2541 — the signature a `prop` / `const` accessor contributes to `class_name#method_name`,
178
178
  # walking the lexical superclass chain the way Ruby's method lookup does. A class on the way that
179
179
  # `def`s the name itself (or declares it with `attr_*`) stops the walk with nil, leaving the user's
180
- # method to the sig lookup and the engine's own tiers. Returns nil unless the declaring class descends from a {STRUCT_ROOTS} root, so a
181
- # project DSL that happens to be named `prop` is never read as Sorbet's.
180
+ # method to the sig lookup and the engine's own tiers. Returns nil unless the declaring class
181
+ # descends from a {STRUCT_ROOTS} root, so a project DSL that happens to be named `prop` is never
182
+ # read as Sorbet's.
182
183
  def lookup_struct_prop(class_name:, method_name:)
183
184
  return nil if @struct_props.empty?
184
185
 
@@ -15,10 +15,11 @@ module Rigor
15
15
  # parsed by {SigParser} and recorded in the {Catalog} under its qualified `(class_name, method_name,
16
16
  # kind)` key.
17
17
  #
18
- # Anything we don't recognise (a stray `sig { ... }` not followed by a `def`, a `def` with no
19
- # preceding `sig`, malformed sig blocks, etc.) is reported back to the caller through
20
- # `parse_errors:` so the plugin can emit a `plugin.sorbet.parse-error` diagnostic. Walking is
21
- # otherwise infallible — a bad sig block does not abort the catalog build for the rest of the file.
18
+ # A malformed or misplaced `sig` (a stray `sig { ... }` not followed by a `def`, two `sig`s in a row,
19
+ # a block with no `returns` / `void`) is returned from {walk} as a {ParseError} so the plugin can emit
20
+ # a `plugin.sorbet.parse-error` diagnostic. A `def` with no preceding `sig` is not an error; it just
21
+ # records nothing. Walking is otherwise infallible — a bad sig block does not abort the catalog build
22
+ # for the rest of the file.
22
23
  module CatalogWalker
23
24
  # Detected error during walking. `kind` is one of: `:no_block` / `:empty_block` /
24
25
  # `:missing_returns_or_void` / `:duplicate_sig` / `:dangling_sig`.
@@ -388,7 +389,7 @@ module Rigor
388
389
  in_singleton_class || def_node.receiver.is_a?(Prism::SelfNode)
389
390
  end
390
391
 
391
- # Resolves a constant-path node (`Foo::Bar`, `::Foo::Bar`) to its dot-separated name. Returns nil
392
+ # Resolves a constant-path node (`Foo::Bar`, `::Foo::Bar`) to its `::`-joined name. Returns nil
392
393
  # for the rare dynamic-prefix shape so the walker doesn't guess a qualified name in that case.
393
394
  def qualified_name_for(node)
394
395
  case node
@@ -26,8 +26,8 @@ module Rigor
26
26
  # yet acted on; `type_parameters` is recognised and its payload discarded.
27
27
  #
28
28
  # The parser is intentionally tolerant — unknown chain nodes degrade to "the rest of the chain is
29
- # opaque" rather than raising. The plugin emits a diagnostic (`plugin.sorbet.parse-error`) only when
30
- # the entire chain fails to yield either a `returns` or a `void`.
29
+ # opaque" rather than raising. The plugin emits a diagnostic (`plugin.sorbet.parse-error`) when the
30
+ # chain yields neither a `returns` nor a `void`, or the `sig` has no block or an empty one.
31
31
  module SigParser
32
32
  # Modifiers we recognise at any position in the chain. Stored in `:modifiers` on the parse result.
33
33
  RECOGNISED_MODIFIERS = %i[abstract override overridable final].freeze
@@ -60,11 +60,10 @@ module Rigor
60
60
  # @return true when `level` is at or above the `# typed: true` mark. Used by the
61
61
  # `enforce_sigil` config gate (default `true`): with the gate on, only files marked `:true` /
62
62
  # `:strict` / `:strong` contribute their sigs to the catalog. The `:false` (and sigil-less)
63
- # levels still get walked (so RBI files outside the project can be loaded regardless), but their
64
- # sig-derived narrowing is suppressed — matching how Sorbet itself only enforces type errors at
65
- # `# typed: true`+. Assertion recognisers (`T.let` / `T.cast` / `T.must` / `T.bind` /
66
- # `T.assert_type!`) are NOT gated by this: the user wrote them deliberately, so the recogniser
67
- # still fires regardless of sigil.
63
+ # levels still get walked (so parse-error diagnostics still surface), but their sigs go to a
64
+ # discarded catalog — matching how Sorbet itself only enforces type errors at `# typed: true`+.
65
+ # Assertion recognisers (`T.let` / `T.cast` / `T.must` / `T.bind` / `T.assert_type!`) read this
66
+ # too, through `Sorbet#assertion_enforced_here?`, and are skipped at `:false` / `:ignore`.
68
67
  def enforced?(level)
69
68
  %i[true strict strong].include?(level)
70
69
  end
@@ -218,7 +218,7 @@ module Rigor
218
218
 
219
219
  # `T::Class[T]` — Sorbet's "any class object whose instances are at least `T`". Rigor has no exact
220
220
  # analogue (Singleton names a specific class); the closest faithful translation is `Singleton[name]`
221
- # when `T` is a constant, or `Singleton[Object]` for broader applications. Lossy — the
221
+ # when `T` is a constant, or `Singleton[Class]` for any other argument. Lossy — the
222
222
  # `dynamic.sorbet.degraded` diagnostic for this case is deferred.
223
223
  def translate_t_class_subscript(args)
224
224
  inner = args.first
@@ -616,9 +616,8 @@ module Rigor
616
616
  # `enforce_sigil` follow-up — when on (default), files at `:false` (or sigil-less, which Sorbet
617
617
  # treats as `:false`) are STILL walked so parse-error diagnostics surface, but sigs flow into a
618
618
  # discardable catalog rather than the per-run one. Sorbet itself doesn't enforce types at `#
619
- # typed: false`, and Rigor mirrors that for sig contributions. Assertion recognisers (`T.let` /
620
- # `T.cast` / `T.must` / `T.bind` / `T.assert_type!`) stay live regardless of sigil — the user
621
- # wrote those deliberately.
619
+ # typed: false`, and Rigor mirrors that for sig contributions. Call-site assertion recognition
620
+ # (`T.let` / `T.cast` / …) is gated separately by `assertion_enforced_here?`.
622
621
  sig_catalog = if @enforce_sigil && !SigilDetector.enforced?(level)
623
622
  Catalog.new
624
623
  else
@@ -658,7 +657,7 @@ module Rigor
658
657
  end
659
658
 
660
659
  # ADR-11 light follow-up — `T.reveal_type(expr)` records the inferred type at recogniser time so the
661
- # per-file diagnostic hook can surface the human-facing message. The reveal call's contribution
660
+ # node rule can surface the human-facing message. The reveal call's contribution
662
661
  # already preserved the inferred type for downstream chaining; this hash carries the *display*
663
662
  # string that the diagnostic shows.
664
663
  def record_reveal_type_call(call_node, return_type)
@@ -0,0 +1,9 @@
1
+ module Rigor
2
+ module Analysis
3
+ module CheckRules
4
+ module Suppression
5
+ def self?.filter_suppressed: (Array[Diagnostic] diagnostics, comments: untyped, disabled_rules: Array[String]) -> Array[Diagnostic]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Rigor
2
+ module Analysis
3
+ # The process-wide gates every recording call site asks first (#3315). The rest of the module is undeclared.
4
+ module DependencyRecorder
5
+ def self?.active?: () -> bool
6
+ def self?.recording?: () -> bool
7
+ end
8
+ end
9
+ end
@@ -14,10 +14,132 @@ module Rigor
14
14
  def statements_or_nil: (untyped statements_node) -> Type::t
15
15
  def fallback_for: (untyped node, family: Symbol) -> Type::t
16
16
  def record_fallback: (untyped node, family: Symbol, inner_type: Type::t) -> void
17
+ def resolve_constant_name: (String name, ?rooted: bool, ?caller_derived: bool) -> Type::t?
17
18
  def type_of_virtual: (untyped node) -> Type::t
18
19
  def call_receiver_type_for: (untyped node) -> Type::t?
19
20
  def call_arg_types: (untyped node) -> Array[Type::t]
20
21
  def block_return_type_for: (untyped call_node, Type::t? receiver_type, Array[Type::t] arg_types) -> Type::t?
22
+
23
+ # The call ladder's port (ADR-116 WD12): with `scope`, the methods a rung module under `call_ladder/` may call
24
+ # on the typer it is given. @api private: each is public only for those modules.
25
+ def positional_correspondence: (untyped call_node, Array[Type::t] arg_types) -> ([Array[untyped], false] | [Array[Type::t], false] | [[Type::t], true])
26
+ def infer_user_method_return: (untyped def_node, Type::t receiver, Array[Type::t] arg_types, ?self_fold_safe: bool, ?yield_type: Type::t?, ?refinements: untyped, ?positionals_unknown: bool) -> Type::t?
27
+ def degrade_if_overridable: (Type::t result, untyped owner, Symbol method_name, Symbol kind) -> Type::t
28
+
29
+ # The entries of the node-typer modules under `expression_typer/` that sig-gen renders a return for, and the
30
+ # private helpers that receive `typer` and that sig-gen renders a return for (without a declaration `typer`
31
+ # reads `Dynamic[top]` inside them). The rest is undeclared (#3315): a row there would be residue.
32
+ module Composites
33
+ def self?.type_of_statements_node: (untyped node, ExpressionTyper typer) -> Type::t
34
+ def self?.type_of_program: (untyped node, ExpressionTyper typer) -> Type::t
35
+ def self?.type_of_hash: (untyped node, ExpressionTyper typer) -> (Type::HashShape | Type::Nominal)
36
+ def self?.type_of_interpolated_string: (untyped node, ExpressionTyper typer) -> (Type::Nominal | Type::Refined)
37
+ def self?.type_of_embedded_statements: (untyped node, ExpressionTyper typer) -> Type::t
38
+ def self?.type_of_class_or_module: (untyped node, ExpressionTyper typer) -> Type::t
39
+ def self?.type_of_else: (untyped node, ExpressionTyper typer) -> Type::t
40
+ def self?.type_of_when_or_in: (untyped node, ExpressionTyper typer) -> Type::t
41
+ def self?.type_of_ensure: (untyped node, ExpressionTyper typer) -> Type::t
42
+ def self?.type_of_range: (untyped node, ExpressionTyper typer) -> (Type::Constant | Type::Nominal)
43
+ def self?.type_of_shareable_constant: (untyped node, ExpressionTyper typer) -> Type::t
44
+ def self?.type_of_implicit: (untyped node, ExpressionTyper typer) -> Type::t
45
+ def self?.array_type_for: (untyped node, ExpressionTyper typer) -> (Type::Nominal | Type::Tuple)
46
+ def self?.parentheses_type_for: (untyped node, ExpressionTyper typer) -> Type::t
47
+ def self?.statements_or_nil: (untyped statements_node, ExpressionTyper typer) -> Type::t
48
+ def self?.static_hash_shape_for: (untyped elements, ExpressionTyper typer) -> (Type::HashShape | nil)
49
+ def self?.generic_hash_pairs_for: (untyped elements, ExpressionTyper typer) -> [Array[untyped], Array[untyped]]
50
+ def self?.interpolation_part_literal?: (untyped part, ExpressionTyper typer) -> (false | true)
51
+ def self?.nominal_range_for_endpoints: (untyped left_node, untyped right_node, ExpressionTyper typer) -> Type::Nominal
52
+ def self?.static_range_endpoint: (untyped node, ExpressionTyper typer) -> ([false, nil] | [true, Float | Integer | String] | [true, nil])
53
+ def self?.statements_type_for: (untyped statements_node, ExpressionTyper typer) -> Type::t
54
+ end
55
+
56
+ module Writes
57
+ def self?.type_of_assignment_write: (untyped node, ExpressionTyper typer) -> Type::t
58
+ def self?.type_of_compound_variable_write: (untyped node, Scope scope, ExpressionTyper typer) -> Type::t
59
+ def self?.type_of_compound_constant_write: (untyped node, Scope scope, ExpressionTyper typer) -> Type::t
60
+ def self?.type_of_index_compound_write: (untyped node, Scope scope, FallbackTracer? tracer) -> Type::t
61
+ def self?.compound_write_value: (untyped node, Type::t? current, Type::t rhs, Scope scope, ExpressionTyper typer) -> Type::t
62
+ def self?.compound_write_constant_binding: (untyped node, Scope scope, ExpressionTyper typer) -> Type::t?
63
+ def self?.written_constant_binding: (String full_name, bool rooted, Scope scope, ExpressionTyper typer) -> Type::t?
64
+ def self?.unnamed_path_binding: (untyped target, Scope scope, ExpressionTyper typer) -> Type::Dynamic?
65
+ def self?.compound_operator_result: (Type::t current, Type::t rhs, untyped operator, Scope scope, ExpressionTyper typer) -> Type::t
66
+ end
67
+ end
68
+
69
+ # The rung modules of the call ladder (ADR-116 WD12). A rung's entry is `try_call(site, typer)`: the site is the
70
+ # call, and the typer is the walking `ExpressionTyper`, declared so that what a rung calls on it is typed.
71
+ module CallLadder
72
+ module UserMethod
73
+ def self?.try_call: (MethodDispatcher::CallContext site, ExpressionTyper typer) -> Type::t?
74
+ def self?.infer: (Type::t? receiver, untyped call_node, Array[Type::t] arg_types, Symbol method_name, Type::t? block_type, ExpressionTyper typer) -> Type::t?
75
+ def self?.user_inference_receiver?: (Type::t? receiver) -> bool
76
+ def self?.fold_safe_call_receiver?: (untyped call_node, Scope scope) -> bool
77
+ def self?.materialization_call?: (untyped node, Scope scope) -> bool
78
+ def self?.resolve_typing_def_with_owner: (String class_name, Symbol method_name, ExpressionTyper typer) -> untyped
79
+ def self?.compute_typing_def_with_owner: (String class_name, Symbol method_name, Scope scope) -> ([untyped, untyped] | [nil, nil, Array[untyped]?] | [nil, nil] | nil)
80
+ def self?.every_definer_raises_type: (Array[untyped]? defs, Type::t receiver, untyped call_node, Array[Type::t] arg_types, Type::t? block_type, ExpressionTyper typer) -> Type::Bot?
81
+ def self?.every_project_definer: (String class_name, Symbol method_name, Scope scope) -> Array[untyped]?
82
+ def self?.definer_without_single_body?: (String owner, Symbol method_name, untyped node, Scope scope) -> untyped
83
+ def self?.external_declares?: (Array[String] candidates, Symbol method_name, Scope scope) -> bool
84
+ end
85
+
86
+ module ProjectSingleton
87
+ def self?.try_call: (MethodDispatcher::CallContext site, ExpressionTyper typer) -> Type::t?
88
+ def self?.try_singleton_method_inference: (Type::t? receiver, untyped call_node, Array[Type::t] arg_types, Symbol method_name, Type::t? block_type, ExpressionTyper typer) -> Type::t?
89
+ def self?.resolve_singleton_def_with_owner: (String class_name, Symbol method_name, ExpressionTyper typer) -> untyped
90
+ def self?.compute_singleton_def_with_owner: (String class_name, Symbol method_name, Scope scope) -> (Array[untyped] | [::Prism::DefNode, String] | [nil, nil])
91
+ def self?.unseen_definer_split?: (String class_name, Symbol method_name, untyped found, Scope scope) -> untyped
92
+ def self?.foreign_definer_behind_copy?: (Symbol method_name, untyped found, Scope scope) -> bool
93
+ def self?.hidden_hook_split?: (String class_name, Symbol method_name, untyped owner, Scope scope) -> untyped
94
+ def self?.hook_block_rival?: (String class_name, Symbol method_name, untyped owner, Scope scope) -> untyped
95
+ def self?.hidden_hook_definer?: (String class_name, Symbol method_name, untyped owner, Scope scope) -> bool
96
+ def self?.singleton_hook_order_split?: (String class_name, Symbol method_name, Scope scope) -> untyped
97
+ def self?.singleton_mixin_split?: (String class_name, Symbol method_name, untyped found, Scope scope) -> untyped
98
+ def self?.singleton_prepend_split?: (String class_name, Symbol method_name, untyped found, Scope scope) -> untyped
99
+ def self?.unnamed_singleton_mixin_split?: (String class_name, Symbol method_name, Scope scope) -> untyped
100
+ def self?.positioned_singleton_definer: (untyped chain, Symbol method_name, Scope scope, ?copies: bool) -> untyped
101
+ def self?.singleton_copy_head: (untyped owner, untyped node, Scope scope) -> untyped
102
+ def self?.dynamic_singleton_definer_ahead?: (String class_name, Symbol method_name, untyped owner, Scope scope) -> bool
103
+ def self?.entry_defines_without_def?: (untyped entry, Symbol name, Scope scope) -> untyped
104
+ def self?.try_singleton_object_constant_inference: (Type::t? receiver, untyped call_node, Array[Type::t] arg_types, Symbol method_name, Type::t? block_type, ExpressionTyper typer) -> Type::t?
105
+ end
106
+
107
+ module LiteralSend
108
+ def self?.try_call: (MethodDispatcher::CallContext site, ExpressionTyper typer) -> Type::t?
109
+ def self?.own_send_type: (untyped node, Type::t? receiver, Array[untyped] args, ExpressionTyper typer) -> Type::t?
110
+ end
111
+
112
+ module TopLevelDef
113
+ def self?.try_call: (MethodDispatcher::CallContext site, ExpressionTyper typer) -> Type::t?
114
+ def self?.declined_top_level_def_answer: (Symbol method_name, Scope scope) -> Type::Dynamic?
115
+ def self?.infer_top_level_user_method: (untyped def_node, Type::t? receiver, untyped call_node, Array[Type::t] arg_types, Type::t? block_type, ExpressionTyper typer) -> Type::t?
116
+ def self?.self_type_answers?: (Symbol method_name, ExpressionTyper typer) -> untyped
117
+ def self?.plugin_member_answers?: (untyped node, Type::t? receiver, Symbol method_name, Scope scope) -> bool
118
+ def self?.instance_self_answers?: (String? class_name, Symbol method_name, ExpressionTyper typer) -> bool
119
+ def self?.rbs_ancestor_answers?: (String class_name, Symbol method_name, Scope scope) -> bool
120
+ def self?.singleton_self_answers?: (String? class_name, Symbol method_name, Scope scope) -> untyped
121
+ def self?.meta_member?: (String class_name, Symbol method_name, Scope scope) -> bool
122
+ end
123
+
124
+ module OverridingDef
125
+ def self?.try_call: (MethodDispatcher::CallContext site, ExpressionTyper typer) -> Type::t?
126
+ def self?.overriding_own_def?: (Type::t? receiver, Symbol method_name, ExpressionTyper typer) -> bool
127
+ def self?.project_declared_owner?: (untyped definition, Scope scope) -> bool
128
+ end
129
+
130
+ module Refined
131
+ def self?.try_call: (MethodDispatcher::CallContext site, ExpressionTyper typer) -> Type::t?
132
+ def self?.refined_indirect_result: (untyped node, Type::t? receiver, Array[String | Symbol] list, Symbol method_name, Scope scope) -> Type::Dynamic?
133
+ def self?.literal_method_name_argument: (untyped node) -> Symbol?
134
+ def self?.symbol_block_argument: (untyped node) -> Symbol?
135
+ def self?.refined_name_for?: (Type::t? receiver, Symbol name, Array[String | Symbol] list, Scope scope) -> bool
136
+ def self?.opaque_refinement_span?: (untyped node, Array[String | Symbol] list, Scope scope) -> untyped
137
+ def self?.refined_receiver?: (Type::t? receiver) -> bool
138
+ def self?.refined_receiver_result: (untyped node, Type::t? receiver, Array[String | Symbol] list, Array[Type::t] arg_types, Type::t? block_type, Symbol method_name, ExpressionTyper typer) -> Type::t?
139
+ def self?.refined_member_result: (untyped node, Type::t? receiver, Array[String | Symbol] list, Array[Type::t] arg_types, Type::t? block_type, Symbol method_name, ExpressionTyper typer) -> Type::t?
140
+ def self?.refined_class_object_result: (untyped _node, Type::Singleton receiver, Array[String | Symbol] list, Array[Type::t] _arg_types, Type::t? _block_type, Symbol method_name, Scope scope) -> Type::Dynamic?
141
+ def self?.refined_body_return: (untyped winner, untyped call_node, Type::Nominal self_type, Array[Type::t] arg_types, Type::t? block_type, Symbol method_name, ExpressionTyper typer) -> Type::t?
142
+ end
21
143
  end
22
144
 
23
145
  class StatementEvaluator
@@ -54,10 +176,26 @@ module Rigor
54
176
  def record_closure_escape_if_any: (untyped node) -> Scope
55
177
  def evaluate_block_if_present: (untyped node) -> void
56
178
  def eval_class_body: (untyped node, Array[ClassFrame] new_context) -> [Type::t, Scope]
179
+ # @api private: public for DefArgumentsAndAssertions (undeclared, below), which calls it back on the evaluator it is given.
180
+ def eval_def: (untyped node) -> [Type::Constant, Scope]
181
+
182
+ # The two entries `HANDLERS` reaches through `StatementEvaluator`. `bind_rescue_reference`, `apply_in_pattern_bindings`
183
+ # and the private helpers are undeclared: sig-gen renders no return for them (`sig.skipped.untyped-return`, #3315).
184
+ module PatternBindings
185
+ def self?.eval_match_pattern: (untyped node, Scope scope, FallbackTracer? tracer, StatementEvaluator evaluator) -> [Rigor::Type::App | Rigor::Type::Bot | Rigor::Type::BoundMethod | Rigor::Type::Constant | Rigor::Type::DataClass | Rigor::Type::DataInstance | Rigor::Type::Difference | Rigor::Type::Dynamic | Rigor::Type::FloatRange | Rigor::Type::HashShape | Rigor::Type::IntegerRange | Rigor::Type::Intersection | Rigor::Type::Maybe | Rigor::Type::Nominal | Rigor::Type::Refined | Rigor::Type::Result | Rigor::Type::Singleton | Rigor::Type::StructClass | Rigor::Type::StructInstance | Rigor::Type::Top | Rigor::Type::Tuple | Rigor::Type::Union, untyped]
186
+ def self?.eval_match_write: (untyped node, Scope scope, StatementEvaluator evaluator) -> [Rigor::Type::App | Rigor::Type::Bot | Rigor::Type::BoundMethod | Rigor::Type::Constant | Rigor::Type::DataClass | Rigor::Type::DataInstance | Rigor::Type::Difference | Rigor::Type::Dynamic | Rigor::Type::FloatRange | Rigor::Type::HashShape | Rigor::Type::IntegerRange | Rigor::Type::Intersection | Rigor::Type::Maybe | Rigor::Type::Nominal | Rigor::Type::Refined | Rigor::Type::Result | Rigor::Type::Singleton | Rigor::Type::StructClass | Rigor::Type::StructInstance | Rigor::Type::Top | Rigor::Type::Tuple | Rigor::Type::Union, untyped]
187
+ end
188
+
189
+ # `DefArgumentsAndAssertions` has no declaration: sig-gen renders a return for only one of its entries
190
+ # (`apply_rspec_matcher_narrowing`), and typing its `current_scope` as `Scope` turns on a self-check error on
191
+ # `narrow.fetch(:local)` (#3315).
57
192
  end
58
193
 
59
194
  module MethodDispatcher
60
195
  def self?.dispatch: (receiver_type: Type::t?, method_name: Symbol, arg_types: Array[Type::t], ?block_type: Type::t?, ?environment: Environment?) -> Type::t?
196
+ # `dispatch` for a caller that built the `CallContext` itself, and the tier ladder both entries end in (ADR-116 WD12).
197
+ def self?.dispatch_site: (CallContext context) -> Type::t?
198
+ def self?.resolve_site: (CallContext context, ?plugin_typed_sink: Array[untyped]?, ?skip_project_patched: bool) -> Type::t?
61
199
  def self?.expected_block_param_types: (receiver_type: Type::t?, method_name: Symbol, arg_types: Array[Type::t], ?environment: Environment?) -> Array[Type::t]
62
200
 
63
201
  # Immutable value object threaded through every dispatch tier.
@@ -73,6 +211,7 @@ module Rigor
73
211
  attr_reader public_only: bool
74
212
 
75
213
  def self.build: (receiver: Type::t?, method_name: Symbol, args: Array[Type::t], ?block_type: Type::t?, ?environment: Environment?, ?call_node: untyped, ?scope: untyped, ?self_type_override: Type::t?, ?public_only: bool) -> CallContext
214
+ def initialize: (Type::t? receiver, Symbol method_name, Array[Type::t] args, Type::t? block_type, Environment? environment, untyped call_node, untyped scope, Type::t? self_type_override, bool public_only) -> void
76
215
  def with: (**untyped) -> CallContext
77
216
  end
78
217
 
@@ -81,6 +220,116 @@ module Rigor
81
220
  interface _DispatchTier
82
221
  def try_dispatch: (CallContext) -> Type::t?
83
222
  end
223
+
224
+ # The dispatch tiers (#3315). Each `try_dispatch` is reached only with the `CallContext` the dispatcher builds.
225
+ module ArithmeticSequenceElements
226
+ def self?.try_dispatch: (CallContext context) -> (Type::Nominal | nil)
227
+ end
228
+ module ArrayToHFolding
229
+ def self?.try_dispatch: (CallContext context) -> (Type::Nominal | nil)
230
+ end
231
+ module BlockFolding
232
+ def self?.try_dispatch: (CallContext context) -> untyped
233
+ end
234
+ module CGIFolding
235
+ def self?.try_dispatch: (CallContext context) -> (Type::Constant | nil)
236
+ end
237
+ module CompositeReceiver
238
+ def self?.try_dispatch: (CallContext context) -> Type::t?
239
+ end
240
+ module ConstantFolding
241
+ def self?.try_dispatch: (CallContext context) -> untyped
242
+ end
243
+ module DataFolding
244
+ def self?.try_dispatch: (CallContext context) -> untyped
245
+ end
246
+ module DependencySource
247
+ def self?.try_dispatch: (CallContext context) -> (Type::Dynamic | nil)
248
+ end
249
+ module DiscoveredMethod
250
+ def self?.try_dispatch: (CallContext context) -> (Type::Dynamic | nil)
251
+ end
252
+ module FileFolding
253
+ def self?.try_dispatch: (CallContext context) -> (Type::Constant | Type::Tuple | nil)
254
+ end
255
+ module HashTransformKeysFolding
256
+ def self?.try_dispatch: (CallContext context) -> Type::t?
257
+ end
258
+ module HktBuiltinReturn
259
+ def self?.try_dispatch: (CallContext context) -> untyped
260
+ end
261
+ module JSONFolding
262
+ def self?.try_dispatch: (CallContext context) -> (Type::Nominal | nil)
263
+ end
264
+ module KernelDispatch
265
+ def self?.try_dispatch: (CallContext context) -> Type::t?
266
+ end
267
+ module MatchDataFolding
268
+ def self?.try_dispatch: (CallContext context) -> (Type::Tuple | nil)
269
+ end
270
+ module MathFolding
271
+ def self?.try_dispatch: (CallContext context) -> (Type::Constant | Type::FloatRange | Type::Tuple | nil)
272
+ end
273
+ module MetaIntrospection
274
+ def self?.try_dispatch: (CallContext context) -> untyped
275
+ end
276
+ module PluginContribution
277
+ def self?.try_dispatch: (CallContext context) -> untyped
278
+ end
279
+ module ProcessFolding
280
+ def self?.try_dispatch: (CallContext context) -> untyped
281
+ end
282
+ module ProjectPatched
283
+ def self?.try_dispatch: (CallContext context, ?through_ancestors: bool) -> (Type::Dynamic | nil)
284
+ end
285
+ module RandomFolding
286
+ def self?.try_dispatch: (CallContext context) -> (Type::FloatRange | Type::IntegerRange | nil)
287
+ end
288
+ module RbsDispatch
289
+ def self?.try_dispatch: (CallContext context) -> untyped
290
+ end
291
+ module ReduceFolding
292
+ def self?.try_dispatch: (CallContext context) -> Type::t?
293
+ end
294
+ module RegexpFolding
295
+ def self?.try_dispatch: (CallContext context) -> Type::t?
296
+ end
297
+ module SetFolding
298
+ def self?.try_dispatch: (CallContext context) -> (Type::Constant | Type::Nominal | nil)
299
+ end
300
+ module ShapeDispatch
301
+ def self?.try_dispatch: (CallContext context) -> untyped
302
+ end
303
+ module ShellwordsFolding
304
+ def self?.try_dispatch: (CallContext context) -> (Type::Constant | Type::Tuple | nil)
305
+ end
306
+ module SingletonMixinDispatch
307
+ def self?.try_dispatch: (CallContext context) -> (Type::Nominal | nil)
308
+ end
309
+ module StaticRefinement
310
+ def self?.try_dispatch: (CallContext context) -> untyped
311
+ end
312
+ module StructFolding
313
+ def self?.try_dispatch: (CallContext context) -> untyped
314
+ end
315
+ module SynthesizedStub
316
+ def self?.try_dispatch: (CallContext context) -> (Type::Dynamic | nil)
317
+ end
318
+ module SyntheticMethodDispatch
319
+ def self?.try_dispatch: (CallContext context) -> untyped
320
+ end
321
+ module TimeFolding
322
+ def self?.try_dispatch: (CallContext context) -> (Type::Constant | nil)
323
+ end
324
+ module UniversalObjectDispatch
325
+ def self?.try_dispatch: (CallContext context) -> untyped
326
+ end
327
+ module URIFolding
328
+ def self?.try_dispatch: (CallContext context) -> (Type::Constant | Type::Tuple | nil)
329
+ end
330
+ module UserClassFallback
331
+ def self?.try_dispatch: (CallContext context) -> untyped
332
+ end
84
333
  end
85
334
 
86
335
  class MethodParameterBinder
@@ -117,11 +366,17 @@ module Rigor
117
366
  def self?.predicate_scopes: (untyped node, Scope scope) -> [Scope, Scope]
118
367
  def self?.case_when_scopes: (untyped subject, Array[untyped] conditions, Scope scope) -> [Scope, Scope]
119
368
  def self?.analyse: (untyped node, Scope scope) -> [Scope, Scope]?
120
- def self?.subclass_of?: (String rigor_class_name, String target_class_name, untyped context) -> bool
121
- def self?.class_ordering: (String lhs, String rhs, untyped context) -> Symbol
122
- def self?.trusted_equality_literal?: (untyped literal) -> bool
123
- def self?.falsey_value?: (untyped value) -> bool
124
- def self?.falsey_nominal?: (Type::Nominal nominal) -> bool
369
+
370
+ module ClassDispatch
371
+ def self?.subclass_of?: (String rigor_class_name, String target_class_name, untyped context) -> bool
372
+ def self?.class_ordering: (String lhs, String rhs, untyped context) -> Symbol
373
+ end
374
+
375
+ module Complements
376
+ def self?.trusted_equality_literal?: (untyped literal) -> bool
377
+ def self?.falsey_value?: (untyped value) -> bool
378
+ def self?.falsey_nominal?: (Type::Nominal nominal) -> bool
379
+ end
125
380
 
126
381
  VALUE_EQUALITY_CLASSES: Array[Class]
127
382
  end
@@ -161,23 +416,32 @@ module Rigor
161
416
 
162
417
  module ScopeIndexer
163
418
  def self?.index: (untyped root, default_scope: Scope) -> Hash[untyped, Scope]
164
- def self?.build_declaration_artifacts: (untyped root) -> [Hash[untyped, Type::t], Hash[String, Type::t]]
165
- def self?.build_in_source_constants: (untyped root, Scope default_scope) -> Hash[String, Type::t]
166
- def self?.record_declarations: (untyped node, Array[String] qualified_prefix, Hash[untyped, Type::t] identity_table, Hash[String, Type::t] discovered) -> void
167
419
  def self?.discovered_classes_for_paths: (Array[String] paths, ?buffer: untyped) -> Hash[String, Type::t]
168
420
  def self?.discovered_def_index_for_paths: (Array[String] paths, ?buffer: untyped) -> Hash[Symbol, untyped]
169
421
  def self?.scan_summary_for_paths: (Array[String] paths, ?buffer: untyped) -> Hash[Symbol, untyped]
170
422
  def self?.code_fingerprint: (String source, untyped comments) -> String
171
423
  def self?.discovered_project_index_for_paths: (Array[String] paths, ?buffer: untyped) -> Hash[Symbol, untyped]
172
424
  def self?.discovered_project_index_incremental: (Array[String] paths, seed_bundles: Hash[String, untyped], ?buffer: untyped) -> Hash[Symbol, untyped]
173
- def self?.collect_class_decls: (untyped node, Array[String] qualified_prefix, Hash[String, Type::t] accumulator) -> void
174
- def self?.constant_writes_for_file: (untyped root) -> Hash[String, untyped]
175
- def self?.constant_literal_value: (untyped rvalue) -> Array[untyped]?
176
425
  # authored: the `Set[String]` values are source paths by contract; a Set's element type stays `untyped` in sig-gen (#2177, #2317), so the generator
177
426
  # would never propose it.
178
427
  def self?.finalize_constant_writes: (Hash[String, Hash[String, untyped]] writes) -> [Hash[String, Type::Constant], Hash[String, Set[String]]]
179
428
  def self?.propagate: (untyped node, Hash[untyped, Scope] table, Scope parent_scope) -> void
180
429
 
430
+ module ClassDeclarations
431
+ def self?.collect_class_decls: (untyped node, Array[String] qualified_prefix, Hash[String, Type::t] accumulator, ?untyped compacts, ?untyped self_prefix, ?singleton_cref: untyped) -> void
432
+ end
433
+
434
+ module ConstantTables
435
+ def self?.build_in_source_constants: (untyped root, Scope default_scope) -> Hash[String, Type::t]
436
+ def self?.constant_writes_for_file: (untyped root) -> Hash[String, untyped]
437
+ def self?.constant_literal_value: (untyped rvalue) -> Array[untyped]?
438
+ end
439
+
440
+ module DeclarationArtifacts
441
+ def self?.build_declaration_artifacts: (untyped root, ?untyped declared_names) -> [Hash[untyped, Type::t], Hash[String, Type::t]]
442
+ def self?.record_declarations: (untyped node, Array[String] qualified_prefix, Hash[untyped, Type::t] identity_table, Hash[String, Type::t] discovered, ?untyped renames, ?untyped self_prefix, ?singleton_cref: untyped) -> void
443
+ end
444
+
181
445
  class LayeredDefNestings
182
446
  def initialize: (Hash[untyped, Array[String]] file, Scope::DiscoveryIndex::def_nestings seed) -> void
183
447
  def []: (untyped def_node) -> Array[String]?