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
@@ -52,10 +52,11 @@ module Rigor
52
52
  # - gem: rigor-activerecord
53
53
  # config:
54
54
  # schema_file: "db/schema.rb"
55
+ # structure_sql_file: "db/structure.sql"
55
56
  # model_search_paths: ["app/models"]
56
57
  # model_base_classes: ["ApplicationRecord", "ActiveRecord::Base"]
57
58
  #
58
- # All three keys default to the values shown above. The class name `Rigor::Plugin::Activerecord` (single
59
+ # All four keys default to the values shown above. The class name `Rigor::Plugin::Activerecord` (single
59
60
  # capital R) is intentional — keeps the constant lookup distinct from `::ActiveRecord` even though the
60
61
  # gem name is hyphenated.
61
62
  #
@@ -65,6 +66,10 @@ module Rigor
65
66
  manifest(
66
67
  id: "activerecord",
67
68
  target_gems: ["activerecord"],
69
+ # 0.17.0, 2026-11-25 (#3322) — `SchemaTable::Column` gains a `not_null` member, so a cached 0.16.0
70
+ # payload is not Marshal-compatible; and a nullable column's reader is now answered optimistically
71
+ # nil-free, which changes what a warm run must serve.
72
+ #
68
73
  # 0.16.0, 2026-11-13 (#2956) — the `id` column takes the primary key's type (`id: :uuid` reads `String`)
69
74
  # instead of always `Integer`, and `serial` / `bigserial` columns read `Integer`. The schema table
70
75
  # payload changes, so the bump follows the 0.15.0 entry.
@@ -132,7 +137,7 @@ module Rigor
132
137
  # a scope lambda body / class-method body now contributes `Relation[Model]` via `scope.self_type`
133
138
  # instead of falling through to `Kernel#select` (the IO multiplexer, `Array[String]` return). Plus
134
139
  # `:select` added to the relation-entry-point list.
135
- version: "0.16.0",
140
+ version: "0.17.0",
136
141
  description: "Types ActiveRecord finders against the project's db/schema.rb and AR models.",
137
142
  config_schema: {
138
143
  "schema_file" => { kind: :string, default: "db/schema.rb" },
@@ -420,8 +425,8 @@ module Rigor
420
425
  names
421
426
  end
422
427
 
423
- # Resolution body for `dynamic_return` — same four-path order, returning the bare type the contract
424
- # expects.
428
+ # Resolution body for `dynamic_return` — same four-path order, returning a type, or for a nullable
429
+ # column read an `optimistic_nil_free` answer (#3322).
425
430
  def contribution_return_type(call_node, scope)
426
431
  return nil unless call_node.is_a?(Prism::CallNode)
427
432
 
@@ -812,6 +817,11 @@ module Rigor
812
817
  # contributing `T | nil` would light up that idiom with `possible-nil-receiver` across an entire
813
818
  # codebase. Under-reporting a nil column is a false negative; over-reporting it is a false positive
814
819
  # — and the project ranks the latter as the worse failure.
820
+ #
821
+ # #3322 — the same omission must not become a proof in the other direction. A column the schema does not
822
+ # prove `NOT NULL` ({SchemaTable::Column#not_null?}) is answered through `optimistic_nil_free`, so the engine
823
+ # still types `user.completed_at` as `Time` but does not fold `if user.completed_at.present?` (or `.nil?`,
824
+ # or the bare read) to a constant and report `flow.always-truthy-condition` on the nil check.
815
825
  def column_return_type(entry, method_name)
816
826
  name = method_name.to_s
817
827
  predicate = name.end_with?("?")
@@ -821,6 +831,11 @@ module Rigor
821
831
  return nil if column.nil?
822
832
  return bool_type if predicate
823
833
 
834
+ type = column_value_type(entry, column, column_name)
835
+ column.not_null? || type.is_a?(Rigor::Type::Dynamic) ? type : optimistic_nil_free(type)
836
+ end
837
+
838
+ def column_value_type(entry, column, column_name)
824
839
  # #1089 — an enum-backed column reads as its KEY (`"active"`), not its SQL storage type
825
840
  # (`Integer` for a `t.integer :status` column). Rails returns the configured key as a String from
826
841
  # the reader (`user.status # => "active"`), so typing it by `column.ruby_type` makes a correct
@@ -940,7 +955,7 @@ module Rigor
940
955
  schema_table_or_nil
941
956
  # ADR-60 WD3 record-and-validate: the producer's own in-block `ModelDiscoverer` reads are
942
957
  # captured into the dependency descriptor after the block runs, and the producer's `watch:` covers
943
- # model-file additions — so no priming walk is needed (it used to run the discover twice).
958
+ # model-file additions — so no priming walk is needed.
944
959
  @model_index = cache_for(:model_index, params: {}).call
945
960
  rescue StandardError => e
946
961
  @load_errors << { key: "2-model-index-failed",
@@ -17,7 +17,7 @@ module Rigor
17
17
  # attachments: [{ name: "avatar", kind: :singular },
18
18
  # { name: "photos", kind: :collection }] }
19
19
  #
20
- # Limitations (intentional for v0.1.0 of the plugin):
20
+ # Limitations (intentional):
21
21
  #
22
22
  # - The walker matches any class declaration that contains a `has_*_attached` call. Whether the
23
23
  # class IS an ActiveRecord model is not verified here — `rigor-activerecord` provides that check
@@ -19,8 +19,9 @@ module Rigor
19
19
  # plugin's `IoBoundary`, walks each `.rb` file with Prism, and collects `has_one_attached :avatar` /
20
20
  # `has_many_attached :photos` macros into an {AttachmentIndex} keyed by class name. The walker is
21
21
  # stand-alone (mirrors `rigor-activerecord`'s `ModelDiscoverer`) so the plugin works even when
22
- # `rigor-activerecord` is not loaded; when it IS loaded, the published `:model_index` fact (ADR-9
23
- # cross-plugin API) drives the same class set so the two plugins agree on what counts as a model.
22
+ # `rigor-activerecord` is not loaded. The manifest declares an optional `consumes` on that plugin's
23
+ # published `:model_index` fact (ADR-9 cross-plugin API), but nothing reads the fact yet: the class set
24
+ # comes from this plugin's own discovery pass alone.
24
25
  #
25
26
  # ## Configuration
26
27
  #
@@ -91,7 +91,7 @@ module Rigor
91
91
  why: "rewrites the process/fiber's time zone for everything downstream"),
92
92
  row(TIME, :use_zone, ["global.write"], singleton: true,
93
93
  why: "swaps the zone around a block; the block's own origins join by containment"),
94
- # Issue #658 declares these three in the RBS bundle, so they get their attributions here for
94
+ # Issue #658 declares these four in the RBS bundle, so they get their attributions here for
95
95
  # the same reason `DateTime#in_time_zone` did: the impurity is invisible at the signature.
96
96
  row(TIME, :zone_default, ZONE_READ, singleton: true,
97
97
  why: "the `attr_accessor` behind `Time.zone`'s fallback — the same mutable process state"),
@@ -13,9 +13,10 @@ module Rigor
13
13
  # root and `Environment.for_project` merges it into the RBS environment, so the ActiveSupport
14
14
  # core-extension selectors (`3.days`, `"x".squish`, `Time.current`, …) resolve.
15
15
  #
16
- # The one exception is the {DURATION_MULTIPLIERS} pair of `dynamic_return` rules, which give `1.day` /
17
- # `5.minutes` an `ActiveSupport::Duration` nominal and keep the arithmetic around it honest. They
18
- # cannot live in the RBS bundle; see the comment on that constant for why.
16
+ # The exception is the `dynamic_return` rules: the {DURATION_MULTIPLIERS} rule and the Duration
17
+ # arithmetic rule give `1.day` / `5.minutes` an `ActiveSupport::Duration` nominal and keep the arithmetic
18
+ # around it honest (see the comment on that constant for why they are not RBS), and the
19
+ # `symbolize_keys` / `to_options` rule maps each key member ({SymbolizeKeys}).
19
20
  #
20
21
  # Issue #632 — `sig/active_support/core_ext.rbs` now ALSO declares `ActiveSupport::Duration` itself
21
22
  # (the reader surface: `ago`/`until`/`since`/`from_now`/`before`/`after`, `to_i`/`in_seconds`, `to_f`,
@@ -27,7 +28,7 @@ module Rigor
27
28
  # `method_missing`). Declaring it now is safe because `ActiveSupport::Duration` is protected TWICE:
28
29
  # this manifest's own `open_receivers:` (ADR-26, below — the mechanism `rigor-activerecord` uses for
29
30
  # `ActiveRecord::Relation`) covers the plugin-loaded path, and
30
- # `Rigor::Analysis::CheckRules::GEM_OVERLAY_OPEN_RECEIVERS` covers the auto-applied
31
+ # `Rigor::Analysis::CheckRules::ReceiverPredicates::GEM_OVERLAY_OPEN_RECEIVERS` covers the auto-applied
31
32
  # `data/gem_overlay/activesupport/core_ext.rbs` twin (issue #449's overlay-has-no-manifest gap — see that
32
33
  # constant's comment). Either alone would keep `call.undefined-method` from ever firing against a
33
34
  # Duration receiver; both exist because a plugin manifest cannot protect a receiver an unrelated,
@@ -94,7 +95,7 @@ module Rigor
94
95
  # yet, not because RBS still cannot express it. `Duration`'s real surface is `method_missing`-forwarded
95
96
  # to the wrapped numeric plus `ago` / `since` / `from_now` / `until` / `before` / `after` / `in_*` /
96
97
  # `iso8601` and every `Numeric` operator, so "omits a member" is guaranteed. The contribution tier sits ABOVE
97
- # `RbsDispatch` (`MethodDispatcher#resolve`), so declaring the multiplier in RBS and typing it here
98
+ # `RbsDispatch` (`MethodDispatcher#resolve_site`), so declaring the multiplier in RBS and typing it here
98
99
  # is not a contradiction: the RBS declaration is what makes `1.day` resolve at all, and this supplies
99
100
  # the answer the declaration deliberately withholds.
100
101
  #
@@ -114,7 +115,7 @@ module Rigor
114
115
 
115
116
  # The nominal every multiplier returns. It is a *lenient* nominal: the site becomes a concrete
116
117
  # receiver that `coverage --protection` counts, and `call.undefined-method` never fires against it
117
- # (ADR-26 `open_receivers:` below) regardless of what its RBS does or doesn't enumerate. Issue #632
118
+ # (ADR-26 `open_receivers:` above) regardless of what its RBS does or doesn't enumerate. Issue #632
118
119
  # gave `ActiveSupport::Duration` an actual (partial) RBS declaration — `sig/active_support/
119
120
  # core_ext.rbs`'s reader surface, `to_i` / `in_seconds` / `to_f` / the `in_minutes` family / `iso8601`
120
121
  # / `parts` — so THOSE now resolve precisely instead of to `Dynamic`. `ago` / `until` / `before` /
@@ -144,7 +145,7 @@ module Rigor
144
145
 
145
146
  # ## Duration arithmetic — a correction, not a feature
146
147
  #
147
- # Typing the multiplier alone REGRESSES three shapes, measured on a fixture before this rule existed.
148
+ # Typing the multiplier alone REGRESSES four shapes, measured on a fixture before this rule existed.
148
149
  # A Duration is an ordinary argument to the core operators, and the overload selector has to choose
149
150
  # among `Time#-`'s `(Time) -> Float` / `(Numeric) -> Time` with an argument whose class it has no RBS
150
151
  # for. Given `Dynamic[top]` — the pre-#534 answer — it widened to the union of the returns and stayed
@@ -57,7 +57,7 @@ module Rigor
57
57
  # enclosing constant chain.
58
58
  # - `required(:key).<predicate>(:type_symbol_or_constant)` rows for the canonical-type vocabulary
59
59
  # above.
60
- # - Publishes the table; no user-facing diagnostics yet.
60
+ # - Publishes the table; no diagnostics in this slice.
61
61
  #
62
62
  # Landed since: typed `result.to_h` returns, via the {.dynamic_return} rule below rather than the
63
63
  # ADR-16 Tier C substrate the README originally projected — Tier C synthesises methods on a class
@@ -276,7 +276,7 @@ module Rigor
276
276
  end
277
277
  private_class_method :dry_types_call?
278
278
 
279
- # Resolves a `Prism::ConstantPathNode` / `Prism::ConstantReadNode` chain to its dot-separated
279
+ # Resolves a `Prism::ConstantPathNode` / `Prism::ConstantReadNode` chain to its `::`-joined
280
280
  # name (e.g. `"App::Types"`). Returns nil for the dynamic-prefix shape so the scanner treats
281
281
  # those as opaque rather than guessing.
282
282
  def qualified_name_for(node)
@@ -20,7 +20,7 @@ module Rigor
20
20
  # and publishes the resulting `{aliased_name => underlying_class}` table as the `:dry_type_aliases`
21
21
  # cross-plugin fact (ADR-9). Other dry-rb adapter plugins consume this fact:
22
22
  #
23
- # - `rigor-dry-struct` reads it so `attribute :city, Types::String` promotes `address.city` from
23
+ # - `rigor-dry-struct` reads it so `attribute :city, Types::String` promotes `address.city`
24
24
  # from an untyped value to `String` via ADR-18's `returns_from_arg:` fact lookup.
25
25
  # - `rigor-dry-validation` / `rigor-dry-schema` read it for per-key type recognition in `schema { … }`
26
26
  # / `params { … }` blocks (separate plugin slice).
@@ -65,12 +65,11 @@ module Rigor
65
65
  )
66
66
 
67
67
  # Cached alias-table producer (ADR-60 WD3 record-and-validate). The scan Prism-parses every `.rb` file
68
- # under the project's `paths:` tree to find `include Dry.Types()` declarations — an expensive pass that
69
- # ran on EVERY invocation (cold and warm) because `#prepare` called {AliasScanner.scan} directly, with
70
- # no cache. It now rides `cache_for`: a warm run re-globs + re-digests the watched tree (cheap SHA over
71
- # file bytes, no AST build) and reuses the cached table instead of re-parsing. This is the dominant win
72
- # even for a project that ships no dry-types module — the parse still has to run to prove that, and now
73
- # the empty result is cached too.
68
+ # under the project's `paths:` tree to find `include Dry.Types()` declarations, which is expensive, so
69
+ # it rides `cache_for`: a warm run re-globs + re-digests the watched tree (cheap SHA over file bytes,
70
+ # no AST build) and reuses the cached table instead of re-parsing. That holds even for a project that
71
+ # ships no dry-types module — the parse has to run once to prove that, and the empty result is cached
72
+ # too.
74
73
  #
75
74
  # `watch:` covers exactly the files the scan reads: one glob per project `paths:` entry, co-extensive
76
75
  # with {#scannable_paths}. A {Cache::Descriptor::GlobEntry} digests every file matching its glob, so a
@@ -19,7 +19,8 @@ module Rigor
19
19
  #
20
20
  # - `factory :users do ... end` — symbol form
21
21
  # - `factory "users" do ... end` — string form
22
- # - `factory :users, aliases: [:author] do ... end` — alias form
22
+ # - `factory :users, aliases: [:author] do ... end` — alias form (indexed under `:users` only; the
23
+ # aliases are not registered)
23
24
  #
24
25
  # Inside a factory block, attribute declarations come in several shapes. Only literal-name forms
25
26
  # are recognised (Symbol arg / String arg):
@@ -77,7 +78,7 @@ module Rigor
77
78
  nil
78
79
  end
79
80
 
80
- # Yields `(factory_name, [attribute_names])` for every `factory :name do ... end` call
81
+ # Yields `(factory_name, attribute_names, model_class)` for every `factory :name do ... end` call
81
82
  # discovered in the subtree. The walker recurses into top-level wrapping blocks
82
83
  # (`FactoryBot.define do ... end`) and into arbitrary container nodes so factories inside
83
84
  # `module` / `class` blocks are still picked up.
@@ -7,8 +7,8 @@ module Rigor
7
7
  module Plugin
8
8
  class Graphql < Rigor::Plugin::Base
9
9
  # Walks project source for `class T < GraphQL::Schema::Object` subclasses and emits a
10
- # `{type_class_fqn => {field_name => {type:, nullable:}}}` table covering every `field :name, Type,
11
- # null: ...` declaration inside the class body.
10
+ # `{type_class_fqn => {field_name => {type:, nullable:, list:}}}` table covering every
11
+ # `field :name, Type, null: ...` declaration inside the class body.
12
12
  module TypeScanner
13
13
  # The canonical GraphQL scalar type names accepted as `field`'s second positional argument. The
14
14
  # plugin maps each to the underlying Ruby class name so downstream consumers can cross-reference
@@ -31,7 +31,8 @@ module Rigor
31
31
  SCHEMA_MUTATION_TAIL = "Mutation"
32
32
  # Common path-segment for `Schema::Object` / `Schema::Enum` / `Schema::InputObject` /
33
33
  # `Schema::Mutation`; the second-to-last segment must be `Schema` (either fully-qualified
34
- # `GraphQL::Schema::X` or lexically nested `Schema::X` inside `module GraphQL`).
34
+ # `GraphQL::Schema::X` or lexically nested `Schema::X` inside `module GraphQL`) or, as the list
35
+ # below also admits, `GraphQL`.
35
36
  SCHEMA_PARENT_SEGMENTS = %w[Schema GraphQL].freeze
36
37
  private_constant :SCHEMA_OBJECT_TAIL, :SCHEMA_ENUM_TAIL,
37
38
  :SCHEMA_INPUT_OBJECT_TAIL, :SCHEMA_MUTATION_TAIL,
@@ -26,8 +26,9 @@ module Rigor
26
26
  # engine substitutes these types for the usual `Dynamic[Top]` fallback, so misuse of `request` or
27
27
  # `response` inside an action body surfaces as a core diagnostic.
28
28
  #
29
- # 2. **Check** that every class under `app/actions/` defines `#handle`. Missing definitions emit
30
- # `missing-handle-method`.
29
+ # 2. **Check** that every class under `app/actions/` defines `#handle` with exactly two required
30
+ # parameters. Missing definitions emit `missing-handle-method`; any other required-parameter count
31
+ # emits `handle-arity-mismatch`.
31
32
  #
32
33
  # Return-type conformance is NOT checked — Hanami actions are void by contract, and checking a void
33
34
  # return would produce false positives on every `if` branch that doesn't end with an explicit `nil`.
@@ -44,6 +45,7 @@ module Rigor
44
45
  # | Event | Severity | Rule |
45
46
  # | --- | --- | --- |
46
47
  # | action class defines no `#handle` | `:error` | `missing-handle-method` |
48
+ # | `#handle` lacks exactly 2 required params | `:error` | `handle-arity-mismatch` |
47
49
  # | `request` / `response` misuse in body | core engine diagnostic |
48
50
  #
49
51
  # A misused `request` or `response` (e.g. `request.no_such_method`) surfaces as a standard engine
@@ -59,7 +59,7 @@ module Rigor
59
59
  )
60
60
 
61
61
  # ADR-37 slice 2 — emits `post_return_facts` for every recognised assertion, method-gated by the
62
- # engine. The engine routes `:local`-kind facts through `StatementEvaluator#apply_local_post_return_fact`.
62
+ # engine. The engine routes `:local`-kind facts through `StatementEvaluator::DefArgumentsAndAssertions.apply_local_post_return_fact`.
63
63
  narrowing_facts methods: AssertionAnalyzer::SUPPORTED_METHODS do |call_node, scope|
64
64
  AssertionAnalyzer.contribution_for(call_node, scope: scope)&.post_return_facts
65
65
  end
@@ -12,7 +12,7 @@ module Rigor
12
12
  # rigor-pundit — validates Pundit `authorize` / `policy` / `policy_scope` calls against the project's
13
13
  # `app/policies/` tree.
14
14
  #
15
- # Tier 3B of the [Rails plugins roadmap](../../../../docs/design/20260508-rails-plugins-roadmap.md).
15
+ # Tier 3B of the [Rails plugins roadmap](../../../../../docs/design/20260508-rails-plugins-roadmap.md).
16
16
  # Statically discovers policy classes by walking `policy_search_paths` and parsing each file with
17
17
  # Prism — no `pundit` runtime dependency.
18
18
  #
@@ -18,12 +18,14 @@ module Rigor
18
18
  # - `plugin.rails-i18n.missing-locale` (warning) when the key resolves in some configured locales but
19
19
  # is absent from at least one. Suppressed when the call passes `default:` (the user has signalled
20
20
  # they're aware of the partial coverage).
21
- # - `plugin.rails-i18n.wrong-interpolation` (error) when the call's interpolation hash uses keys that
22
- # don't match the value's `%{var}` placeholders, or omits a required placeholder.
21
+ # - `plugin.rails-i18n.wrong-interpolation` (error) when the call omits a `%{var}` placeholder the
22
+ # value requires.
23
+ # - `plugin.rails-i18n.extra-interpolation` (warning) when the call passes a non-reserved keyword the
24
+ # value has no placeholder for.
23
25
  module Analyzer
24
26
  TRANSLATE_METHODS = %i[t translate].freeze
25
27
 
26
- # Methods that are always I18n receivers (`I18n.t`, `::I18n.t`).
28
+ # Constant receivers that always mean I18n (`I18n.t`, `::I18n.t`).
27
29
  I18N_RECEIVER_NAMES = %w[I18n ::I18n].freeze
28
30
 
29
31
  # Matches controller file paths so lazy keys (`.key`) can be expanded to
@@ -11,7 +11,7 @@ module Rigor
11
11
  module Plugin
12
12
  # rigor-rails-i18n — validates `t('key.path')` / `I18n.t(...)` calls against `config/locales/*.yml`.
13
13
  #
14
- # Tier 1B of the [Rails plugins roadmap](../../../../docs/design/20260508-rails-plugins-roadmap.md).
14
+ # Tier 1B of the [Rails plugins roadmap](../../../../../docs/design/20260508-rails-plugins-roadmap.md).
15
15
  # Statically reads every YAML file under `locale_search_paths` (default `config/locales/`), builds a
16
16
  # flat `dotted_key => Entry` index keyed by the leaf key path, and validates every `t(literal_key, ...)`
17
17
  # call site against the catalogue. No Rails runtime dependency.
@@ -17,12 +17,11 @@ module Rigor
17
17
  # Scope:
18
18
  #
19
19
  # - Recognises the standard controllers (`:sessions`, `:passwords`, `:confirmations`, `:unlocks`,
20
- # `:registrations`, `:omniauth_callbacks`).
20
+ # `:registrations`); `:omniauth_callbacks` contributes only the two scoped arity-2 helpers.
21
21
  # - Honours `skip: [...]` to suppress controllers the project disables.
22
- # - Honours `path: "..."` to remap the URL path (does NOT remap the helper-name prefix — Devise uses
23
- # the resource name for the helper, not the path).
24
- # - Does NOT yet honour `as: "..."` overrides, `class_name:`, `controllers: { ... }` (these are rare;
25
- # expand on demand).
22
+ # - Does NOT honour `path: "..."` (it remaps only the URL path; Devise names the helpers after the
23
+ # resource, so the helper set is unaffected and the entry's `path` is informational), `as: "..."`
24
+ # overrides, `class_name:` or `controllers: { ... }` (these are rare; expand on demand).
26
25
  # - `omniauth_callbacks` helpers are dynamic — the provider name is supplied at call time
27
26
  # (`user_facebook_omniauth_authorize_path`) and Devise declares them from the configured providers,
28
27
  # which live in an initializer this static parser does not read. The suffix patterns are registered
@@ -23,8 +23,8 @@ module Rigor
23
23
  # - Does NOT yet honour custom `as:` / `at:` on `use_doorkeeper` itself.
24
24
  module DoorkeeperRoutes
25
25
  # Per-controller helper catalogue. Keys are the `skip_controllers :<key>` names; values are the
26
- # entries (name + arity + path + http_method). Both `_path` and `_url` variants are paired by
27
- # `RoutesParser` after registration.
26
+ # entries (name + arity + path + http_method + action). Both `_path` and `_url` variants are
27
+ # listed explicitly.
28
28
  CONTROLLER_HELPERS = {
29
29
  authorizations: [
30
30
  ["oauth_authorization_path", 0, "/oauth/authorize", :get, :show],
@@ -7,10 +7,11 @@ require "prism"
7
7
  module Rigor
8
8
  module Plugin
9
9
  class RailsRoutes < Rigor::Plugin::Base
10
- # Walks the configured `helper_paths:` directories (default `app/`) and extracts every public
11
- # module-level method name so the analyzer's `unknown-helper` rule does not false-fire on calls to
12
- # project-defined `*_path` / `*_url` helpers (the canonical Rails pattern: a `UrlHelper` module
13
- # exposing `full_asset_url`, `host_to_url`, `frontend_asset_url`, and so on).
10
+ # Walks the configured `helper_paths:` directories (default `app/`) and extracts every instance-method
11
+ # name ending in `_path` / `_url` defined at module / class level (any visibility) so the analyzer's
12
+ # `unknown-helper` rule does not false-fire on calls to project-defined `*_path` / `*_url` helpers
13
+ # (the canonical Rails pattern: a `UrlHelper` module exposing `full_asset_url`, `host_to_url`,
14
+ # `frontend_asset_url`, and so on).
14
15
  #
15
16
  # The discoverer is deliberately conservative:
16
17
  #
@@ -17,7 +17,8 @@ module Rigor
17
17
  # for helpers that span multiple methods (a `resources` show helper isn't HTTP-method-specific in
18
18
  # the helper sense — it's path-sensitive only).
19
19
  # - `action`: `:index` / `:show` / `:new` / `:edit` / `:create` / `:update` / `:destroy` for
20
- # resourceful routes; `:custom` for explicit `get`/`post`/etc.; `:root` for the root route.
20
+ # resourceful routes; `:custom` for explicit `get`/`post`/etc.; `:root` for the root route; `:mount` for
21
+ # a `mount` point's `as:` helper.
21
22
  #
22
23
  # Both `_path` and `_url` forms share the same metadata — the table records each helper twice (once
23
24
  # with `_path`, once with `_url`) for `O(1)` lookup at the call site.
@@ -26,7 +27,7 @@ module Rigor
26
27
 
27
28
  attr_reader :entries, :custom_helpers, :devise_resources
28
29
 
29
- # @param entries — freshly built; the factory below is the canonical construction path.
30
+ # @param entries — the route-helper {Entry} rows.
30
31
  # @param custom_helpers — names of project-defined helper methods (typically
31
32
  # pulled from `app/helpers/**/*.rb` by {HelperDiscoverer}) that the analyzer should treat as
32
33
  # known — they do NOT correspond to a route but their presence MUST NOT fire `unknown-helper`. No
@@ -22,17 +22,15 @@ module Rigor
22
22
  # - `resource :name`
23
23
  # - `get/post/patch/put/delete "path", to:, as:`
24
24
  # - `root to: "..."` / `root "..."`
25
- # - `scope "path", as: :name do ... end` (with `as:` key)
26
- # - One level of `namespace :foo do ... end`
27
- # - One level of nested `resources` (`resources :users do; resources :posts; end`)
25
+ # - `scope "path", as: :name do ... end`, and the `path:` / `module:` / `controller:` keyword forms
26
+ # - `namespace :foo do ... end`
27
+ # - Nested `resources` (`resources :users do; resources :posts; end`)
28
28
  # - `member do ... end` / `collection do ... end` inside `resources`
29
+ # - `mount Engine, as:, at:` (registers the `<as>_path` helper only), `direct(:name) { |obj| ... }`
29
30
  #
30
- # Out of scope for v0.1.0 (silent skips):
31
+ # Not interpreted (silent skips):
31
32
  #
32
- # - `scope path:` / `scope module:` (path/module-only, no `as:`)
33
33
  # - Constraints (`constraints: { id: /\d+/ }`)
34
- # - `mount` / engine routes
35
- # - `direct(:name) { |obj| ... }`
36
34
  # - Format restrictions
37
35
  module RoutesParser
38
36
  # Standard resource actions Rails generates by default.
@@ -89,7 +87,7 @@ module Rigor
89
87
  controllers: context.controller_class_names)
90
88
  end
91
89
 
92
- # For every registered alias rule `(from_str, to_str, arity_delta)`, find every existing entry whose
90
+ # For every registered alias rule `(from_str, to_str)`, find every existing entry whose
93
91
  # name contains `from_str` and register an aliased entry with `from_str → to_str` substitution. The
94
92
  # pattern matches GitLab's shorthand-helper idiom: a loop over registered route names that invokes
95
93
  # `direct(new_name) do |project, *args| send("#{name}_url", project&.namespace, project, *args) end`
@@ -410,8 +408,8 @@ module Rigor
410
408
  end
411
409
 
412
410
  # ADR-39: inflection delegates to the shared `Rigor::Plugin::Inflector`, which uses the real
413
- # `ActiveSupport::Inflector` (the authority Rails uses to generate helper names) when available,
414
- # and a built-in approximation otherwise.
411
+ # `ActiveSupport::Inflector` (the authority Rails uses to generate helper names) and has no
412
+ # built-in approximation: when ActiveSupport cannot be loaded it raises rather than guess.
415
413
  def singularize(word)
416
414
  Rigor::Plugin::Inflector.singularize(word)
417
415
  end
@@ -612,7 +610,7 @@ module Rigor
612
610
  context.push_namespace(name) { interpret_block_body(node, context) }
613
611
  end
614
612
 
615
- # `devise_for :users [, skip: [...], path: "..."]` — generates the standard Devise route-helper
613
+ # `devise_for :users [, skip: [...]]` — generates the standard Devise route-helper
616
614
  # catalogue for the named resource. Symbol-literal first arg only; non-literal forms (e.g. dynamic
617
615
  # resource names built from constants) are silently skipped because the helper SET depends on the
618
616
  # literal name and we cannot statically resolve a variable here. `skip:` is read so the project's
@@ -644,7 +642,8 @@ module Rigor
644
642
  end
645
643
 
646
644
  # `mount Foo::Engine, at: '/path', as: :name` — mounted Rails engines. The mount adds a single
647
- # helper for the mount point itself: `<as>_path` / `<as>_url` (arity 0). The engine's own internal
645
+ # helper for the mount point itself: `<as>_path` / `<as>_url` (arity = the enclosing scopes' dynamic
646
+ # segment count, 0 at top level). The engine's own internal
648
647
  # helpers are out of scope (they'd need the engine's routes.rb available; almost no static parser
649
648
  # follows that). Mastodon uses `mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq` and similar.
650
649
  #
@@ -705,8 +704,9 @@ module Rigor
705
704
  # adds the given prefix to every helper registered inside. Dynamic path segments (`:slug`) are
706
705
  # counted so nested-resource arities stay correct.
707
706
  #
708
- # When `as:` is absent the block is interpreted without any prefix change — helper names are
709
- # unaffected by the scope's path, which matches Rails' behaviour for path-only scopes.
707
+ # When `as:` is absent helper names are unaffected by the scope's path, which matches Rails'
708
+ # behaviour for path-only scopes; a path carrying dynamic segments still contributes its path and
709
+ # arity (see `interpret_scope_frame`).
710
710
  def handle_scope(node, context)
711
711
  options = options_hash(node)
712
712
  context.push_module(options[:module]) do
@@ -801,13 +801,6 @@ module Rigor
801
801
  end
802
802
  end
803
803
 
804
- # ADR-102 WD3 — the controller a `resources` / `resource` declaration dispatches to.
805
- #
806
- # `resources :users` serves `UsersController`; a SINGULAR `resource :profile` serves the PLURAL
807
- # `ProfilesController` — Rails pluralises the controller even though the routes are singular, and
808
- # that is the one point where the two shapes disagree. An explicit `controller:` wins outright,
809
- # including its `controller: "admin/users"` module-path and `controller: "/users"` absolute forms.
810
- #
811
804
  # Whether a `resources` / `resource` declaration actually routes anything to its own controller.
812
805
  #
813
806
  # `only: []` strips every default action, and the two shapes it appears in mean opposite things:
@@ -841,6 +834,13 @@ module Rigor
841
834
  end
842
835
  end
843
836
 
837
+ # ADR-102 WD3 — the controller a `resources` / `resource` declaration dispatches to.
838
+ #
839
+ # `resources :users` serves `UsersController`; a SINGULAR `resource :profile` serves the PLURAL
840
+ # `ProfilesController` — Rails pluralises the controller even though the routes are singular, and
841
+ # that is the one point where the two shapes disagree. An explicit `controller:` wins outright,
842
+ # including its `controller: "admin/users"` module-path and `controller: "/users"` absolute forms.
843
+ #
844
844
  # `only: []` (or an `except:` that removes every action) declares no routes at all and so names no
845
845
  # controller; the callers gate on {#routed?} rather than this method re-deriving it.
846
846
  def record_resource_controller(context, options, name, plural:)
@@ -1230,13 +1230,13 @@ module Rigor
1230
1230
  end
1231
1231
  end
1232
1232
 
1233
- # Maps an action keyword to the route-helper entry it produces. The five "named-helper" actions
1234
- # (`:index` / `:show` / `:new` / `:edit` plus singular-resource `:show`) generate a distinct
1235
- # helper; the three "verb-only" actions (`:create` / `:update` / `:destroy`) Rails serves under the
1236
- # same path-helper Rails reuses for show / index forms — so we emit them too, otherwise an `only:
1237
- # [:create]` resource (e.g. Mastodon's `resource :inbox, only: [:create]`) registers NO helpers and
1238
- # downstream callers see a false `unknown-helper inbox_path`. The HelperTable already dedupes by
1239
- # name, so a resource that lists both `:show` and `:update` does not double-register.
1233
+ # Maps an action keyword to the route-helper entry it produces. The four "named-helper" actions
1234
+ # (`:index` / `:show` / `:new` / `:edit`) generate a distinct helper; the three "verb-only" actions
1235
+ # (`:create` / `:update` / `:destroy`) Rails serves under the same path-helper Rails reuses for
1236
+ # show / index forms — so we emit them too, otherwise an `only: [:create]` resource (e.g.
1237
+ # Mastodon's `resource :inbox, only: [:create]`) registers NO helpers and downstream callers see a
1238
+ # false `unknown-helper inbox_path`. A resource listing both `:show` and `:update` therefore adds
1239
+ # two same-named entries; `HelperTable` groups entries by name, so that is harmless.
1240
1240
  def entry_for_action(action, name:, singular:, base_arity:, path_base:, helper_prefix:, plural:)
1241
1241
  case action
1242
1242
  when :index then index_entry(plural, helper_prefix, name, base_arity, path_base, singular)
@@ -1289,9 +1289,8 @@ module Rigor
1289
1289
  # `unknown-helper`.
1290
1290
  #
1291
1291
  # Rails adds `_index_` whenever `singular == plural` — including for UNCOUNTABLE nouns (Redmine's
1292
- # `resources :news` registers `news_index_path` for the index). The earlier "skip UNCOUNTABLE"
1293
- # carve-out was empirically wrong; only the IRREGULAR-singular path (e.g. `media → medium`)
1294
- # actually has `singular != plural` and skips `_index_`.
1292
+ # `resources :news` registers `news_index_path` for the index). Only an IRREGULAR singular (e.g.
1293
+ # `media → medium`) has `singular != plural` and skips `_index_`.
1295
1294
  index_name = if name.to_s == singular
1296
1295
  "#{helper_prefix}#{name}_index_path"
1297
1296
  else
@@ -15,16 +15,16 @@ module Rigor
15
15
  # against the project's `config/routes.rb`.
16
16
  #
17
17
  # Tier 1A of the [Rails plugins roadmap](../../../../../docs/design/20260508-rails-plugins-roadmap.md).
18
- # Statically interprets the routes DSL via Prism — no `rails` runtime dependency. Recognised v0.1.0
19
- # surface:
18
+ # Statically interprets the routes DSL via Prism — no `rails` runtime dependency. Core recognised
19
+ # surface (the parser covers more; its header lists the full set):
20
20
  #
21
21
  # - `Rails.application.routes.draw do ... end`
22
22
  # - `resources :name [, only: [...] | except: [...]]`
23
23
  # - `resource :name`
24
24
  # - `get/post/patch/put/delete "/path", to:, as:`
25
25
  # - `root to: "..."` / `root "..."`
26
- # - One level of `namespace :foo do ... end`
27
- # - One level of nested `resources`
26
+ # - `namespace :foo do ... end`
27
+ # - Nested `resources`
28
28
  #
29
29
  # The plugin publishes its parsed `:helper_table` through the ADR-9 cross-plugin fact store;
30
30
  # `rigor-actionpack` Phase 4 consumes it for route-helper validation in controller code.
@@ -41,14 +41,14 @@ module Rigor
41
41
  # recognises the namespace their `prefix` / `version` declarations open rather than enumerating names
42
42
  # it cannot know.
43
43
  #
44
- # ## Limitations (v0.1.0)
44
+ # ## Limitations
45
45
  #
46
- # - `scope :path:` / `scope :module:` / `scope :as:` are not interpreted — helpers nested inside these
47
- # constructs are silently skipped.
48
- # - Constraints / format restrictions / mountable engines are out of scope.
49
- # - The English inflector is intentionally tiny: it handles `posts` ↔ `post`, `users` ↔ `user`,
50
- # `categories` ↔ `category`, `boxes` ↔ `box`. Custom inflections (`fish` ↔ `fish`, `child` ↔
51
- # `children`) are out of scope; users who need them ship a hand-written RBS for the affected helper.
46
+ # - Constraints and format restrictions are not interpreted; a `mount`ed engine contributes only its
47
+ # own `as:` helper, not the routes inside the engine.
48
+ # - Inflection is the real `ActiveSupport::Inflector` (ADR-39), with no built-in approximation: when it
49
+ # cannot be loaded the inflection-dependent checks go silent rather than guess. Project-specific
50
+ # inflection rules are not read, except the acronyms parsed from `config/initializers/inflections.rb`
51
+ # ({Acronyms}), which only affect controller-class-name composition.
52
52
  class RailsRoutes < Rigor::Plugin::Base
53
53
  manifest(
54
54
  id: "rails-routes",
@@ -231,10 +231,8 @@ module Rigor
231
231
  )
232
232
  end
233
233
 
234
- # The load-error path used to emit the same warning on every analyzed file in the project. On large
235
- # monorepos (Mastodon: 1,302 files; Solidus: ~1,000 files) and on legacy projects without a top-level
236
- # `config/routes.rb`, this multiplied a single root cause into 1,000+ identical diagnostics. The
237
- # error is project-global — report it once per run.
234
+ # The load error is project-global, so `diagnostics_for_file` reports it once per run (via
235
+ # `disclose_load_error`) rather than once per analyzed file.
238
236
 
239
237
  def helper_table_or_nil
240
238
  # Memoise the build *attempt*, not just a truthy result: when the routes file is missing or
@@ -22,7 +22,7 @@ module Rigor
22
22
  ]
23
23
  )
24
24
 
25
- # Issue 2 & 5: use robust positional binding extractor and preserve module context
25
+ # The enclosing module (when the recognizer is handed one) is the receiver; `RbNaCl` is the fallback.
26
26
  ffi_binding_recognizer :sodium_function do |node, module_name|
27
27
  next [] unless node.is_a?(Prism::CallNode) && node.name == :sodium_function
28
28
 
@@ -15,9 +15,10 @@ module Rigor
15
15
  # - `outer_range`: `Range[Integer]` of line numbers covered by the describe's block body
16
16
  # (start_line..end_line).
17
17
  # - `describe_const`: the model constant string named in `RSpec.describe SomeModel do` / `describe
18
- # SomeModel do`, or `nil` when the describe's first arg is a String (`describe ".foo"`).
19
- # - `lets`: `Hash{Symbol => Prism::BlockNode}` of `let(:name) { ... }` and `subject(:name) { ... }`
20
- # declarations. `:subject` is the key for the implicit `subject { ... }`.
18
+ # SomeModel do`; a describe whose first arg is a String (`describe ".foo"`) inherits the enclosing
19
+ # describe's constant, so it is `nil` only when no enclosing describe names one.
20
+ # - `lets`: `Hash{Symbol => Prism::BlockNode}` of `let(:name) { ... }`, `let!(:name) { ... }` and
21
+ # `subject(:name) { ... }` declarations. `:subject` is the key for the implicit `subject { ... }`.
21
22
  #
22
23
  # Used by the plugin's let-binding `dynamic_return` rule to bind `let`-named method-shape calls
23
24
  # inside `it` bodies to the let block's inferred type.