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
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../run_cache_key"
4
+ require_relative "../../effects/effect_table"
5
+
6
+ module Rigor
7
+ module Analysis
8
+ class Runner
9
+ # The reads and writes of the whole-run effects sidecar's two cache entries (ADR-103 WD13 / #382, #482):
10
+ # each is a function of the cache store it is handed and returns the stored value or what the store
11
+ # answered, reading and writing no `Runner` state. {Runner} keeps the serve and store sequences
12
+ # (`serve_effect_collections`, `served_from_effect_entries?`, `store_effect_collections`), which adopt the
13
+ # result into the run's effect tables and decide when to ask.
14
+ module EffectCacheEntries
15
+ module_function
16
+
17
+ # The read half of the serving entry (#482). A miss, a stale dependency, a corrupt entry and a
18
+ # stored value of the wrong shape are one answer — nil, "collect it again" — because none of them
19
+ # can be told apart from the outside and all of them have the same remedy. An entry from before the
20
+ # split simply does not exist under this producer id, so an older cache re-collects once.
21
+ def peek_effect_summary(cache_store, descriptor)
22
+ cached = cache_store.peek_validated(
23
+ producer_id: RunCacheKey::RUN_EFFECTS_TABLE_PRODUCER_ID, key_descriptor: descriptor
24
+ )
25
+ return nil unless cached.is_a?(Array) && cached.length == 3
26
+ return nil unless cached[0].is_a?(Effects::EffectTable) && cached[1].is_a?(Hash) &&
27
+ cached[2].is_a?(Hash)
28
+
29
+ cached
30
+ rescue StandardError
31
+ nil
32
+ end
33
+
34
+ # The read half of the collections entry — only ever asked by {Runner#forced_file_effects}, on the paths
35
+ # that need per-file form. The stored shape is `[collections]`; an entry from before the split is
36
+ # `[collections, table]` and its first member is the same Hash, so it still reads.
37
+ def peek_effect_collections(cache_store, descriptor)
38
+ cached = cache_store.peek_validated(
39
+ producer_id: RunCacheKey::RUN_EFFECTS_PRODUCER_ID, key_descriptor: descriptor
40
+ )
41
+ return nil unless cached.is_a?(Array) && cached.first.is_a?(Hash)
42
+
43
+ cached.first
44
+ rescue StandardError
45
+ nil
46
+ end
47
+
48
+ def write_effect_entry(cache_store, producer_id, descriptor, payload, dependencies)
49
+ cache_store.fetch_or_validate(
50
+ producer_id: producer_id, key_descriptor: descriptor,
51
+ generation_cap: RunCacheKey::EFFECTS_GENERATION_CAP
52
+ ) { [payload, dependencies] }
53
+ end
54
+
55
+ # An empty table over non-empty summaries is {Runner#close_effect_graph}'s fail-soft answer, not a
56
+ # result — persisting it would freeze one run's propagation failure into every warm hit until the
57
+ # next invalidation. Storing nil instead makes the warm hit re-run the fixpoint, which is exactly
58
+ # the retry the fail-soft posture wants.
59
+ def storable_effect_table(effect_table, collections)
60
+ table = effect_table
61
+ return nil if table.nil?
62
+ return nil if table.empty? && collections.any? { |_, collection| !collection.summaries.empty? }
63
+
64
+ table
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -212,10 +212,8 @@ module Rigor
212
212
  end
213
213
 
214
214
  # ADR-15 Phase 4b — routes per-file analysis to either the sequential coordinator-side Environment
215
- # (legacy path, default) or a Ractor worker pool built around {WorkerSession} (opt-in via
216
- # `workers:`). The sequential path is bit-for-bit unchanged from v0.1.4 / earlier; the pool path is
217
- # the substrate exercised by phase 4c when `RIGOR_RACTOR_WORKERS` / `.rigor.yml`
218
- # `parallel.workers:` is wired.
215
+ # (default) or a worker pool built around {WorkerSession} (opt-in via `workers:`, which
216
+ # `RIGOR_RACTOR_WORKERS` / `.rigor.yml` `parallel.workers:` set; the backend is {#pool_backend}'s).
219
217
  #
220
218
  # Sequential mode also snapshots `class_decl_paths` from the local environment after the per-file
221
219
  # loop completes so `RunStats` can attribute the RBS class universe between project-sig and bundled
@@ -608,8 +606,8 @@ module Rigor
608
606
  # run-level facts and disclosures) for end-of-pool merge.
609
607
  #
610
608
  # The Ruby 4.0+ Ractor model uses a single per-Ractor mailbox (no `Ractor.yield`); workers push
611
- # back via `Ractor.main.send`. The coordinator drains its mailbox via `Ractor.receive` until it has
612
- # counted exactly `pool.size` `:done` messages.
609
+ # back via `Ractor.main.send`. The coordinator drains its mailbox via `Ractor.receive` until every
610
+ # worker has terminated (see the monitor loop below).
613
611
  #
614
612
  # Diagnostic order: original path order. Workers may complete files out of order; the coordinator
615
613
  # re-orders via the `results_by_path` Hash before flattening.
@@ -830,8 +828,8 @@ module Rigor
830
828
 
831
829
  # ADR-15 Amendment (2026-05-20) — fork-based worker pool, the active backend for `workers > 0`.
832
830
  # Builds ONE {WorkerSession} on the parent, then `fork`s N children that copy-on-write inherit it.
833
- # Each child analyses a contiguous slice of `files` and writes a Marshal'd `{results:, reporters:}`
834
- # payload to a temp file; the parent `Process.wait`s every child, merges the payloads, and re-orders
831
+ # Each child analyses a contiguous slice of `files` and writes a Marshal'd {WorkerPayload}
832
+ # to a temp file; the parent `Process.wait`s every child, merges the payloads, and re-orders
835
833
  # diagnostics by original path order.
836
834
  #
837
835
  # Separate processes have separate GC heaps and `vm->ci_table` (immune to Ruby Bug #22075) and
@@ -54,7 +54,7 @@ module Rigor
54
54
  # Frozen bundle of the cross-file discovery tables the two whole-project parse passes produce. Split
55
55
  # out of {Result} so the {Runner} can defer these to the analysis (miss) path — a warm cache HIT never
56
56
  # consumes them and so never pays the double parse (see {#discover} + `Runner#ensure_project_discovery`).
57
- # The slot names mirror the discovery half of {Result} exactly.
57
+ # Each slot is adopted onto the {Runner}'s matching `@project_*` discovery ivar.
58
58
  Discovery = Data.define(
59
59
  :discovered_classes, :discovered_def_nodes, :discovered_def_nestings, :discovered_singleton_def_nodes,
60
60
  :discovered_def_sources, :discovered_singleton_def_sources, :discovered_superclasses,
@@ -69,7 +69,7 @@ module Rigor
69
69
  # environment build (and therefore the cache key): plugin load + `#prepare`, the ADR-10
70
70
  # dependency-source index, the ADR-16 synthetic-method scanner, and the ADR-17 project-patched
71
71
  # scanner. The cross-file discovery tables are NOT built here (they are consumed only on the analysis
72
- # path, so they defer to {#discover}); the {Result} carries `nil` for them, matching {#adopt_prebuilt}.
72
+ # path, so they defer to {#discover}); the {Result} has no slot for them.
73
73
  # Extracted so `#prepare_project_scan` and the prebuilt-less `#run` path share one implementation.
74
74
  def run(expansion:)
75
75
  # ADR-90 — resolve the target project's bundle for the plugin isolation layer BEFORE any plugin
@@ -355,9 +355,7 @@ module Rigor
355
355
 
356
356
  # Loads project-configured plugins through {Rigor::Plugin::Loader} and returns the resulting
357
357
  # {Rigor::Plugin::Registry}. Loader failures are isolated: each surfaces as a `:plugin_loader`
358
- # diagnostic on the run's `Result` rather than aborting the analysis. Plugins that load successfully
359
- # but contribute no protocol hooks are inert in slice 1; later v0.1.0 slices wire the contribution
360
- # merger through this registry.
358
+ # diagnostic on the run's `Result` rather than aborting the analysis.
361
359
  def load_plugins
362
360
  return Plugin::Registry::EMPTY if @configuration.plugins.empty?
363
361
 
@@ -0,0 +1,144 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../inference/scope_indexer"
4
+
5
+ module Rigor
6
+ module Analysis
7
+ class Runner
8
+ # The pure parts of {Runner#project_scope_seed_tables}: each fills the `tables` Hash it is handed from the
9
+ # project tables passed beside it (a `Runner` ivar is a parameter of the same name), and reads and writes
10
+ # no `Runner` state. {Runner} keeps the assembly — the order the tables are applied in, the tables whose
11
+ # reads go through a memo (`seed_refinements`, the constant name indexes) or through
12
+ # `PAIRED_MEMBER_IVARS`' ivar names — and calls these once per file's seed.
13
+ module ScopeSeed
14
+ module_function
15
+
16
+ # The three mixin tables: the ADR-24 instance-side `include` map, its issue #1123 `prepend` twin
17
+ # (which carries the instance-ancestor order the include table's set-shaped value cannot), and the
18
+ # #898 singleton-side `extend` table. Grouped here because they are read as one picture of a class's
19
+ # ancestry, and split out of {Runner#project_scope_seed_tables} to keep it under the complexity budget.
20
+ def seed_mixin_tables(tables, project_discovered_includes, project_discovered_prepends,
21
+ project_discovered_extends, project_unpositioned_mixins)
22
+ tables[:discovered_includes] = project_discovered_includes unless project_discovered_includes.empty?
23
+ tables[:discovered_prepends] = project_discovered_prepends unless project_discovered_prepends.empty?
24
+ tables[:discovered_extends] = project_discovered_extends unless project_discovered_extends.empty?
25
+ tables[:unpositioned_mixins] = project_unpositioned_mixins unless project_unpositioned_mixins.empty?
26
+ end
27
+
28
+ # ADR-46 slice 1 / issue #644 — the two SOURCE-ATTRIBUTION tables, read by the recording accessors
29
+ # (`Scope#record_class_dependency` for the class-declaration map, `Scope#record_constant_dependency`
30
+ # for the constant-write map). The class-declaration map rides every run: an ancestor-order reader also
31
+ # asks whether a class is declared in more than one file. The constant-write map rides only a recording
32
+ # run. Extracted to keep {Runner#project_scope_seed_tables} under the complexity budget.
33
+ #
34
+ # Issue #617 — the census's binding writes, grouped by last segment, ride every run instead: a constant
35
+ # compound write whose plain read resolves nothing reads its binding off them, a TYPE rather than an edge.
36
+ # Issue #1290's shadowing writes ride beside them for the lexical ladder, for the same reason.
37
+ def seed_dependency_attribution_tables(tables, writers, shadowers, project_discovered_class_sources,
38
+ record_dependencies, project_constant_sources)
39
+ tables[:constant_writers] = writers unless writers.empty?
40
+ tables[:constant_shadowers] = shadowers unless shadowers.empty?
41
+ tables[:discovered_class_sources] = project_discovered_class_sources unless
42
+ project_discovered_class_sources.empty?
43
+ return unless record_dependencies
44
+
45
+ tables[:constant_sources] = project_constant_sources unless project_constant_sources.empty?
46
+ end
47
+
48
+ # ADR-46 — seed the instance + singleton `"path:line"` def-source tables (each only when non-empty).
49
+ # Extracted to keep {Runner#project_scope_seed_tables} under the complexity budget. The singleton table (slice 4
50
+ # extension) rides the same seed so a pooled `WorkerSession` records singleton symbol edges identically.
51
+ def seed_def_source_tables(tables, project_discovered_def_sources, project_discovered_singleton_def_sources)
52
+ tables[:discovered_def_sources] = project_discovered_def_sources unless project_discovered_def_sources.empty?
53
+ return if project_discovered_singleton_def_sources.empty?
54
+
55
+ tables[:discovered_singleton_def_sources] = project_discovered_singleton_def_sources
56
+ end
57
+
58
+ # ADR-48 — seed the Data + Struct member-layout tables (each only when non-empty). Extracted to keep
59
+ # {Runner#project_scope_seed_tables} under the complexity budget.
60
+ def seed_member_layout_tables(tables, project_data_member_layouts, project_struct_member_layouts)
61
+ tables[:data_member_layouts] = project_data_member_layouts unless project_data_member_layouts.empty?
62
+ return if project_struct_member_layouts.empty?
63
+
64
+ tables[:struct_member_layouts] = project_struct_member_layouts
65
+ end
66
+
67
+ # Issue #644 — the seeded `in_source_constants` table, joining the two cross-file constant producers.
68
+ # The whole-project literal table wins over a `pre_eval:` publication of the same name: both describe
69
+ # the same assignment, the literal table pins the value the write actually carries while ADR-17's
70
+ # widener erases it to the class, and listing a file under `pre_eval:` must never LOSE precision. The
71
+ # per-file table still wins over both (`ScopeIndexer.index`'s merge) — same-file stays the most
72
+ # specific authority.
73
+ #
74
+ # ADR-124 — a `prebuilt:` runner computes no literal table of its own; a `discovery_seed:` (the editor
75
+ # publish, ADR-124) brings the project's, which then plays the same part.
76
+ def merged_seed_constants(project_pre_eval_constants, project_constant_values, discovery_seed,
77
+ project_constant_sources, pre_eval_path_set)
78
+ pre_eval = publishable_pre_eval_constants(project_pre_eval_constants, discovery_seed,
79
+ project_constant_sources, pre_eval_path_set)
80
+ literal = literal_seed_constants(project_constant_values, discovery_seed)
81
+ return literal if pre_eval.empty?
82
+ return pre_eval if literal.empty?
83
+
84
+ pre_eval.merge(literal).freeze
85
+ end
86
+
87
+ # The project's literal constant table: this run's, or the one a `discovery_seed:` carries (ADR-124).
88
+ def literal_seed_constants(project_constant_values, discovery_seed)
89
+ return project_constant_values unless project_constant_values.empty? && discovery_seed
90
+
91
+ discovery_seed.fetch(:in_source_constants, project_constant_values)
92
+ end
93
+
94
+ # The per-name writer paths the #663 retraction reads: this run's census, or the one a `discovery_seed:` carries
95
+ # (ADR-124).
96
+ def constant_writer_sources(project_constant_sources, discovery_seed)
97
+ return project_constant_sources unless project_constant_sources.empty? && discovery_seed
98
+
99
+ discovery_seed.fetch(:constant_sources, project_constant_sources)
100
+ end
101
+
102
+ # Issue #663 — the `pre_eval:` publication with every name an UNLISTED file also assigns retracted.
103
+ # Without this a listed `X = :a` answered `Symbol` at every reader while a sibling `X = "str"` decided
104
+ # the runtime value half the time: a confident wrong type, not lost precision, and the one asymmetry
105
+ # #644's precedence work left standing. The retraction costs the opt-in nothing where it earns its
106
+ # keep — a name only listed files write is untouched, and where the literal table also publishes it
107
+ # already won (above).
108
+ #
109
+ # Conflict is read off #644's write attribution, which censuses every assigning form, so a name the
110
+ # listed file's own typed walk widened is retracted by an unlisted `X += 1` or `A, X = 1, 2` as
111
+ # readily as by a plain reassignment. Among LISTED files the rule is unchanged: `PreEvalConstants`
112
+ # widens first and drops only on disagreement, so two listed files writing `1` and `2` still publish
113
+ # `Integer` rather than being retracted for being two.
114
+ def publishable_pre_eval_constants(project_pre_eval_constants, discovery_seed, project_constant_sources,
115
+ pre_eval_path_set)
116
+ return project_pre_eval_constants if project_pre_eval_constants.empty?
117
+
118
+ listed = pre_eval_path_set
119
+ kept = project_pre_eval_constants.reject do |name, _|
120
+ unlisted_constant_writer?(name, listed, project_constant_sources, discovery_seed)
121
+ end
122
+ kept.size == project_pre_eval_constants.size ? project_pre_eval_constants : kept.freeze
123
+ end
124
+
125
+ # True when some file outside `listed` assigns `name`. The wildcard key is consulted alongside the
126
+ # name's own attribution ([#668](https://github.com/rigortype/rigor/issues/668)): a `k::X = 7` names
127
+ # no target, and a listed file kept out of `paths:` (ADR-17 WD5 permits it) contributes no censused
128
+ # name of its own for the wildcard's paths to have been folded into.
129
+ def unlisted_constant_writer?(name, listed, project_constant_sources, discovery_seed)
130
+ segment = name.split("::").last
131
+ sources = constant_writer_sources(project_constant_sources, discovery_seed)
132
+ writers = sources[name]
133
+ wildcard = sources["#{Inference::ScopeIndexer::DYNAMIC_TARGET_PREFIX}#{segment}"]
134
+ [writers, wildcard].any? do |paths|
135
+ paths&.any? { |path| !listed.include?(File.absolute_path(path)) }
136
+ end
137
+ end
138
+
139
+ private_class_method :publishable_pre_eval_constants, :literal_seed_constants, :constant_writer_sources,
140
+ :unlisted_constant_writer?
141
+ end
142
+ end
143
+ end
144
+ end