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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/docs/handbook/01-getting-started.md +1 -1
- data/docs/handbook/04-tuples-and-shapes.md +6 -1
- data/docs/handbook/12-lightweight-hkt.md +1 -1
- data/docs/handbook/appendix-typescript.md +28 -17
- data/docs/manual/02-cli-reference.md +10 -0
- data/docs/manual/03-configuration.md +1 -1
- data/docs/manual/04-diagnostics.md +1 -1
- data/docs/manual/10-mcp-server.md +122 -10
- data/docs/manual/plugins/rigor-activerecord.md +7 -0
- data/lib/rigor/analysis/check_rules/always_raises.rb +95 -0
- data/lib/rigor/analysis/check_rules/always_truthy_condition_collector.rb +32 -2
- data/lib/rigor/analysis/check_rules/argument_type.rb +802 -0
- data/lib/rigor/analysis/check_rules/call_facts.rb +2 -2
- data/lib/rigor/analysis/check_rules/dead_assignment_collector.rb +30 -1
- data/lib/rigor/analysis/check_rules/declaration_sourced_guard.rb +4 -5
- data/lib/rigor/analysis/check_rules/duplicate_hash_key_collector.rb +34 -0
- data/lib/rigor/analysis/check_rules/ivar_write_collector.rb +131 -4
- data/lib/rigor/analysis/check_rules/nil_receiver.rb +195 -0
- data/lib/rigor/analysis/check_rules/override_param_narrowed.rb +111 -0
- data/lib/rigor/analysis/check_rules/override_return_widened.rb +88 -0
- data/lib/rigor/analysis/check_rules/override_support.rb +246 -0
- data/lib/rigor/analysis/check_rules/override_visibility.rb +135 -0
- data/lib/rigor/analysis/check_rules/published_constant_guard.rb +75 -31
- data/lib/rigor/analysis/check_rules/raise_non_exception.rb +198 -0
- data/lib/rigor/analysis/check_rules/receiver_predicates.rb +576 -0
- data/lib/rigor/analysis/check_rules/return_in_ensure_collector.rb +52 -4
- data/lib/rigor/analysis/check_rules/return_type.rb +225 -0
- data/lib/rigor/analysis/check_rules/rigor_testing.rb +119 -0
- data/lib/rigor/analysis/check_rules/rule_ids.rb +7 -7
- data/lib/rigor/analysis/check_rules/rule_walk.rb +4 -3
- data/lib/rigor/analysis/check_rules/self_closedness_scanner.rb +2 -0
- data/lib/rigor/analysis/check_rules/self_undefined_method.rb +165 -0
- data/lib/rigor/analysis/check_rules/shadowed_rescue_collector.rb +34 -0
- data/lib/rigor/analysis/check_rules/source_arity.rb +2 -2
- data/lib/rigor/analysis/check_rules/special_global_write.rb +256 -0
- data/lib/rigor/analysis/check_rules/suppression.rb +275 -0
- data/lib/rigor/analysis/check_rules/undefined_method.rb +882 -0
- data/lib/rigor/analysis/check_rules/unreachable_branch.rb +97 -0
- data/lib/rigor/analysis/check_rules/unreachable_clause_collector.rb +42 -0
- data/lib/rigor/analysis/check_rules/unresolved_toplevel.rb +140 -0
- data/lib/rigor/analysis/check_rules/visibility_mismatch.rb +252 -0
- data/lib/rigor/analysis/check_rules/void_value_use_collector.rb +27 -0
- data/lib/rigor/analysis/check_rules/wrong_arity.rb +303 -0
- data/lib/rigor/analysis/check_rules.rb +66 -4931
- data/lib/rigor/analysis/dependency_recorder.rb +1 -1
- data/lib/rigor/analysis/dependency_source_inference/builder.rb +2 -4
- data/lib/rigor/analysis/dependency_source_inference/gem_resolver.rb +1 -2
- data/lib/rigor/analysis/dependency_source_inference/walker.rb +15 -15
- data/lib/rigor/analysis/incremental_session.rb +4 -4
- data/lib/rigor/analysis/path_expansion.rb +1 -1
- data/lib/rigor/analysis/plugin_fact_fingerprint.rb +5 -5
- data/lib/rigor/analysis/reachability/graph.rb +2 -3
- data/lib/rigor/analysis/reachability/plugin_roots.rb +2 -2
- data/lib/rigor/analysis/reachability/scan.rb +2 -2
- data/lib/rigor/analysis/rule_catalog.rb +2 -1
- data/lib/rigor/analysis/run_cache_key.rb +9 -8
- data/lib/rigor/analysis/runner/buffer_pool_dispatcher.rb +2 -2
- data/lib/rigor/analysis/runner/dependency_rows.rb +206 -0
- data/lib/rigor/analysis/runner/diagnostic_aggregator.rb +24 -22
- data/lib/rigor/analysis/runner/effect_cache_entries.rb +69 -0
- data/lib/rigor/analysis/runner/pool_coordinator.rb +6 -8
- data/lib/rigor/analysis/runner/project_pre_passes.rb +3 -5
- data/lib/rigor/analysis/runner/scope_seed.rb +144 -0
- data/lib/rigor/analysis/runner.rb +49 -296
- data/lib/rigor/analysis/template_unit_collector.rb +1 -1
- data/lib/rigor/analysis/template_units.rb +10 -10
- data/lib/rigor/analysis/worker_session.rb +7 -7
- data/lib/rigor/bleeding_edge.rb +3 -2
- data/lib/rigor/builtins/hkt_builtins.rb +17 -17
- data/lib/rigor/builtins/imported_refinements.rb +8 -16
- data/lib/rigor/builtins/regex_refinement.rb +3 -3
- data/lib/rigor/builtins/static_return_refinements.rb +143 -19
- data/lib/rigor/cache/incremental_snapshot.rb +21 -8
- data/lib/rigor/cache/rbs_descriptor.rb +18 -1
- data/lib/rigor/cli/coverage_renderer.rb +15 -1
- data/lib/rigor/cli/coverage_report.rb +19 -1
- data/lib/rigor/cli/diagnostic_formats.rb +3 -2
- data/lib/rigor/cli/docs_command.rb +5 -5
- data/lib/rigor/cli/effects_command.rb +7 -6
- data/lib/rigor/cli/fused_protection_report.rb +7 -7
- data/lib/rigor/cli/lsp_command.rb +1 -1
- data/lib/rigor/cli/mcp_command.rb +5 -2
- data/lib/rigor/cli/options.rb +4 -0
- data/lib/rigor/cli/plugins_command.rb +1 -1
- data/lib/rigor/cli/sig_gen_command.rb +1 -1
- data/lib/rigor/cli/skill_command.rb +5 -4
- data/lib/rigor/cli/triage_renderer.rb +3 -2
- data/lib/rigor/cli/unused_command.rb +4 -4
- data/lib/rigor/cli.rb +14 -0
- data/lib/rigor/configuration/coercion.rb +418 -0
- data/lib/rigor/configuration/defaults.rb +248 -0
- data/lib/rigor/configuration/dependencies.rb +1 -1
- data/lib/rigor/configuration/loader.rb +354 -0
- data/lib/rigor/configuration/severity_profile.rb +4 -4
- data/lib/rigor/configuration.rb +51 -860
- data/lib/rigor/effects/attribution.rb +1 -1
- data/lib/rigor/effects/effect_table.rb +1 -1
- data/lib/rigor/effects/identity.rb +3 -3
- data/lib/rigor/effects/local_ownership.rb +2 -2
- data/lib/rigor/effects/snapshot.rb +1 -1
- data/lib/rigor/effects/summary.rb +5 -4
- data/lib/rigor/environment/member_consistency.rb +10 -0
- data/lib/rigor/environment/rbs_loader.rb +19 -22
- data/lib/rigor/environment/reflection.rb +1 -1
- data/lib/rigor/environment/unreadable_signature.rb +21 -0
- data/lib/rigor/environment.rb +8 -8
- data/lib/rigor/flow_contribution/merger.rb +1 -0
- data/lib/rigor/hashing/xxh3.rb +1 -1
- data/lib/rigor/inference/acceptance.rb +23 -2
- data/lib/rigor/inference/alias_mutation_floor/site_collector.rb +5 -0
- data/lib/rigor/inference/alias_mutation_floor.rb +0 -5
- data/lib/rigor/inference/anonymous_meta_class.rb +2 -2
- data/lib/rigor/inference/block_call_timing.rb +6 -0
- data/lib/rigor/inference/budget_trace.rb +3 -2
- data/lib/rigor/inference/builtins/date_catalog.rb +3 -3
- data/lib/rigor/inference/builtins/method_catalog.rb +3 -3
- data/lib/rigor/inference/builtins/time_catalog.rb +3 -3
- data/lib/rigor/inference/call_ladder/literal_send.rb +98 -0
- data/lib/rigor/inference/call_ladder/overriding_def.rb +98 -0
- data/lib/rigor/inference/call_ladder/project_singleton.rb +362 -0
- data/lib/rigor/inference/call_ladder/refined.rb +212 -0
- data/lib/rigor/inference/call_ladder/top_level_def.rb +222 -0
- data/lib/rigor/inference/call_ladder/user_method.rb +247 -0
- data/lib/rigor/inference/call_ladder.rb +219 -0
- data/lib/rigor/inference/callee_write_census.rb +2 -2
- data/lib/rigor/inference/captured_locals.rb +2 -2
- data/lib/rigor/inference/clause_widening.rb +63 -1
- data/lib/rigor/inference/declaration_walk/context.rb +12 -12
- data/lib/rigor/inference/declaration_walk/rules.rb +750 -0
- data/lib/rigor/inference/declaration_walk/traversal.rb +9 -8
- data/lib/rigor/inference/declaration_walk.rb +4 -3
- data/lib/rigor/inference/def_node_resolver.rb +2 -2
- data/lib/rigor/inference/def_return_typer.rb +14 -6
- data/lib/rigor/inference/deferred_mutation.rb +120 -0
- data/lib/rigor/inference/define_method_block_self.rb +1 -1
- data/lib/rigor/inference/definer_resolution.rb +4 -4
- data/lib/rigor/inference/error_info.rb +8 -8
- data/lib/rigor/inference/expression_typer/composites.rb +348 -0
- data/lib/rigor/inference/expression_typer/per_element_assemblers.rb +233 -0
- data/lib/rigor/inference/expression_typer/writes.rb +218 -0
- data/lib/rigor/inference/expression_typer.rb +275 -1825
- data/lib/rigor/inference/external_ancestor_resolution.rb +2 -2
- data/lib/rigor/inference/fallback.rb +1 -0
- data/lib/rigor/inference/for_yield_slots.rb +126 -0
- data/lib/rigor/inference/genuine_send.rb +92 -0
- data/lib/rigor/inference/global_write_census.rb +2 -2
- data/lib/rigor/inference/hkt_body.rb +2 -0
- data/lib/rigor/inference/in_effect_refinements/walk.rb +2 -2
- data/lib/rigor/inference/index_write_widening.rb +4 -4
- data/lib/rigor/inference/indexed_narrowing.rb +1 -1
- data/lib/rigor/inference/intervening_ivar_reset.rb +46 -9
- data/lib/rigor/inference/ivar_writer_census.rb +1 -1
- data/lib/rigor/inference/loop_store_sites.rb +239 -0
- data/lib/rigor/inference/macro_block_self_type.rb +4 -3
- data/lib/rigor/inference/method_dispatcher/block_folding.rb +3 -2
- data/lib/rigor/inference/method_dispatcher/call_context.rb +84 -14
- data/lib/rigor/inference/method_dispatcher/composite_receiver.rb +144 -0
- data/lib/rigor/inference/method_dispatcher/constant_folding.rb +7 -5
- data/lib/rigor/inference/method_dispatcher/declared_constructor.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/dependency_source.rb +90 -0
- data/lib/rigor/inference/method_dispatcher/discovered_method.rb +78 -0
- data/lib/rigor/inference/method_dispatcher/file_folding.rb +2 -2
- data/lib/rigor/inference/method_dispatcher/hkt_builtin_return.rb +40 -0
- data/lib/rigor/inference/method_dispatcher/iterator_dispatch.rb +1 -6
- data/lib/rigor/inference/method_dispatcher/literal_string_folding.rb +4 -2
- data/lib/rigor/inference/method_dispatcher/match_data_folding.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/meta_introspection.rb +506 -0
- data/lib/rigor/inference/method_dispatcher/overload_selector.rb +2 -0
- data/lib/rigor/inference/method_dispatcher/plugin_contribution.rb +134 -0
- data/lib/rigor/inference/method_dispatcher/project_patched.rb +134 -0
- data/lib/rigor/inference/method_dispatcher/rbs_dispatch.rb +125 -43
- data/lib/rigor/inference/method_dispatcher/reduce_folding.rb +3 -4
- data/lib/rigor/inference/method_dispatcher/regexp_folding.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/set_folding.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +19 -6
- data/lib/rigor/inference/method_dispatcher/singleton_folding.rb +3 -3
- data/lib/rigor/inference/method_dispatcher/singleton_mixin_dispatch.rb +7 -4
- data/lib/rigor/inference/method_dispatcher/static_refinement.rb +106 -0
- data/lib/rigor/inference/method_dispatcher/synthesized_stub.rb +41 -0
- data/lib/rigor/inference/method_dispatcher/synthetic_method_dispatch.rb +133 -0
- data/lib/rigor/inference/method_dispatcher/universal_object_dispatch.rb +2 -1
- data/lib/rigor/inference/method_dispatcher/user_class_fallback.rb +216 -0
- data/lib/rigor/inference/method_dispatcher.rb +175 -1361
- data/lib/rigor/inference/method_parameter_binder.rb +18 -18
- data/lib/rigor/inference/module_function_state.rb +5 -4
- data/lib/rigor/inference/mutation_widening.rb +20 -7
- data/lib/rigor/inference/narrowing/case_literals.rb +58 -0
- data/lib/rigor/inference/narrowing/class_dispatch.rb +302 -0
- data/lib/rigor/inference/narrowing/complements.rb +322 -0
- data/lib/rigor/inference/narrowing/presence_predicates.rb +205 -0
- data/lib/rigor/inference/narrowing/regex_match.rb +499 -0
- data/lib/rigor/inference/narrowing.rb +86 -1269
- data/lib/rigor/inference/object_mixins.rb +2 -2
- data/lib/rigor/inference/opaque_mutation.rb +214 -0
- data/lib/rigor/inference/optimistic_origin.rb +52 -14
- data/lib/rigor/inference/parameter_inference_collector.rb +1 -1
- data/lib/rigor/inference/pre_eval_constants.rb +11 -9
- data/lib/rigor/inference/precision_scanner.rb +27 -2
- data/lib/rigor/inference/project_patched_methods.rb +3 -3
- data/lib/rigor/inference/range_constant.rb +3 -3
- data/lib/rigor/inference/rbs_type_translator.rb +2 -2
- data/lib/rigor/inference/refine_self.rb +8 -7
- data/lib/rigor/inference/refined_dispatch.rb +2 -2
- data/lib/rigor/inference/return_barrier.rb +24 -9
- data/lib/rigor/inference/scope_indexer/alias_def_nodes.rb +311 -0
- data/lib/rigor/inference/scope_indexer/census_scope.rb +47 -0
- data/lib/rigor/inference/scope_indexer/certainty.rb +2 -2
- data/lib/rigor/inference/scope_indexer/class_cvar_census.rb +282 -0
- data/lib/rigor/inference/scope_indexer/class_cvars_collector.rb +12 -5
- data/lib/rigor/inference/scope_indexer/class_declarations.rb +228 -0
- data/lib/rigor/inference/scope_indexer/class_ivar_index.rb +2028 -0
- data/lib/rigor/inference/scope_indexer/constant_ivar_value.rb +4 -3
- data/lib/rigor/inference/scope_indexer/constant_tables.rb +844 -0
- data/lib/rigor/inference/scope_indexer/cvar_hierarchy.rb +159 -0
- data/lib/rigor/inference/scope_indexer/declaration_artifacts.rb +219 -0
- data/lib/rigor/inference/scope_indexer/declaration_signature.rb +212 -0
- data/lib/rigor/inference/scope_indexer/def_nestings_collector.rb +2 -2
- data/lib/rigor/inference/scope_indexer/factory_call_resolver.rb +53 -0
- data/lib/rigor/inference/scope_indexer/literal_receiver_mutations.rb +266 -0
- data/lib/rigor/inference/scope_indexer/member_layouts_collector.rb +8 -7
- data/lib/rigor/inference/scope_indexer/mixin_accumulator.rb +1 -1
- data/lib/rigor/inference/scope_indexer/mixin_effects.rb +470 -0
- data/lib/rigor/inference/scope_indexer/mixin_tables.rb +388 -0
- data/lib/rigor/inference/scope_indexer/mutated_carrier_widening.rb +163 -0
- data/lib/rigor/inference/scope_indexer/mutated_element_census.rb +211 -0
- data/lib/rigor/inference/scope_indexer/node_propagation.rb +520 -0
- data/lib/rigor/inference/scope_indexer/program_globals.rb +154 -0
- data/lib/rigor/inference/scope_indexer/published_constant_cvars.rb +146 -0
- data/lib/rigor/inference/scope_indexer/published_constant_ivars.rb +181 -0
- data/lib/rigor/inference/scope_indexer/shared_walk_tables.rb +823 -0
- data/lib/rigor/inference/scope_indexer/singleton_class_sources.rb +85 -0
- data/lib/rigor/inference/scope_indexer/superclasses_collector.rb +5 -5
- data/lib/rigor/inference/scope_indexer.rb +2657 -9558
- data/lib/rigor/inference/self_call_ivar_writes.rb +22 -3
- data/lib/rigor/inference/set_mutation.rb +2 -2
- data/lib/rigor/inference/singleton_hook_definers.rb +185 -0
- data/lib/rigor/inference/statement_evaluator/def_arguments_and_assertions.rb +365 -0
- data/lib/rigor/inference/statement_evaluator/pattern_bindings.rb +581 -0
- data/lib/rigor/inference/statement_evaluator.rb +201 -1008
- data/lib/rigor/inference/synthetic_method_scanner.rb +0 -3
- data/lib/rigor/language_server/completion_provider.rb +8 -8
- data/lib/rigor/language_server/diagnostic_publisher.rb +6 -7
- data/lib/rigor/language_server/document_symbol_provider.rb +4 -6
- data/lib/rigor/language_server/folding_range_provider.rb +3 -3
- data/lib/rigor/language_server/hover_provider.rb +2 -2
- data/lib/rigor/language_server/loop.rb +2 -2
- data/lib/rigor/language_server/server.rb +3 -2
- data/lib/rigor/language_server/signature_help_provider.rb +7 -9
- data/lib/rigor/lens/document.rb +10 -1
- data/lib/rigor/lens/file_reader.rb +2 -1
- data/lib/rigor/mcp/loop.rb +48 -6
- data/lib/rigor/mcp/server.rb +248 -23
- data/lib/rigor/mcp/skill_catalog.rb +157 -0
- data/lib/rigor/plugin/base.rb +22 -4
- data/lib/rigor/plugin/effect_attribution.rb +1 -1
- data/lib/rigor/plugin/inflector.rb +2 -2
- data/lib/rigor/plugin/io_boundary.rb +1 -1
- data/lib/rigor/plugin/loader.rb +4 -4
- data/lib/rigor/plugin/macro/heredoc_template.rb +4 -3
- data/lib/rigor/plugin/optimistic_return.rb +20 -0
- data/lib/rigor/plugin/registry.rb +2 -2
- data/lib/rigor/plugin/template_unit.rb +4 -2
- data/lib/rigor/plugin/trust_policy.rb +2 -1
- data/lib/rigor/plugin.rb +1 -1
- data/lib/rigor/protection/mutator.rb +8 -9
- data/lib/rigor/rbs_extended/reporter.rb +2 -2
- data/lib/rigor/rbs_extended.rb +2 -2
- data/lib/rigor/reflection/constant_ancestors.rb +1 -1
- data/lib/rigor/reflection/project_method.rb +2 -2
- data/lib/rigor/reflection.rb +4 -4
- data/lib/rigor/scope/discovery_index.rb +15 -10
- data/lib/rigor/scope/resolution_chain.rb +29 -6
- data/lib/rigor/scope.rb +89 -32
- data/lib/rigor/sig_gen/generator.rb +5 -4
- data/lib/rigor/sig_gen/renderer.rb +3 -3
- data/lib/rigor/sig_gen/writer.rb +8 -6
- data/lib/rigor/source/parameter_envelope.rb +1 -1
- data/lib/rigor/triage/catalogue.rb +4 -4
- data/lib/rigor/type/combinator.rb +2 -2
- data/lib/rigor/type/data_instance.rb +2 -2
- data/lib/rigor/type/struct_instance.rb +3 -3
- data/lib/rigor/type_node/generic.rb +2 -1
- data/lib/rigor/type_of_memo.rb +2 -1
- data/lib/rigor/typing_state.rb +3 -2
- data/lib/rigor/version.rb +1 -1
- data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/analyzer.rb +2 -2
- data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/channel_discoverer.rb +1 -1
- data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer/mailer_discoverer.rb +4 -4
- data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer.rb +1 -1
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/controller_discoverer.rb +4 -3
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/effects.rb +7 -5
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/erb_compiler.rb +4 -2
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/render_locals.rb +1 -1
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/view_assigns.rb +3 -2
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack.rb +7 -7
- data/plugins/rigor-activejob/lib/rigor/plugin/activejob/job_discoverer.rb +1 -1
- data/plugins/rigor-activejob/lib/rigor/plugin/activejob.rb +2 -2
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_discoverer.rb +9 -8
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_index.rb +3 -2
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_parser.rb +15 -7
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_table.rb +10 -3
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/structure_sql_parser.rb +12 -1
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord.rb +20 -5
- data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage/attachment_discoverer.rb +1 -1
- data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage.rb +3 -2
- data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext/effects.rb +1 -1
- data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext.rb +8 -7
- data/plugins/rigor-dry-schema/lib/rigor/plugin/dry_schema.rb +1 -1
- data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types/alias_scanner.rb +1 -1
- data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types.rb +6 -7
- data/plugins/rigor-factorybot/lib/rigor/plugin/factorybot/factory_discoverer.rb +3 -2
- data/plugins/rigor-graphql/lib/rigor/plugin/graphql/type_scanner.rb +4 -3
- data/plugins/rigor-hanami/lib/rigor/plugin/hanami.rb +4 -2
- data/plugins/rigor-minitest/lib/rigor/plugin/minitest.rb +1 -1
- data/plugins/rigor-pundit/lib/rigor/plugin/pundit.rb +1 -1
- data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n/analyzer.rb +5 -3
- data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n.rb +1 -1
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/devise_routes.rb +4 -5
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/doorkeeper_routes.rb +2 -2
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_discoverer.rb +5 -4
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_table.rb +3 -2
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/routes_parser.rb +30 -31
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes.rb +13 -15
- data/plugins/rigor-rbnacl/lib/rigor/plugin/rbnacl.rb +1 -1
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/let_scope_index.rb +4 -3
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/matcher_analyzer.rb +16 -13
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/scope_walker.rb +3 -2
- data/plugins/rigor-shoulda-matchers/lib/rigor/plugin/shoulda_matchers/analyzer.rb +6 -6
- data/plugins/rigor-sidekiq/lib/rigor/plugin/sidekiq/analyzer.rb +3 -3
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/assertion_recognizer.rb +2 -2
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog.rb +3 -2
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog_walker.rb +6 -5
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sig_parser.rb +2 -2
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sigil_detector.rb +4 -5
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/type_translator.rb +1 -1
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet.rb +3 -4
- data/sig/rigor/analysis/check_rules/suppression.rbs +9 -0
- data/sig/rigor/analysis/dependency_recorder.rbs +9 -0
- data/sig/rigor/inference.rbs +275 -11
- data/sig/rigor/plugin/base.rbs +14 -5
- data/sig/rigor/plugin/optimistic_return.rbs +16 -0
- data/sig/rigor/scope.rbs +7 -1
- data/sig/rigor/source.rbs +4 -0
- data/skills/rigor-mcp-setup/SKILL.md +20 -6
- data/skills/rigor-plugin-review/SKILL.md +3 -3
- data/skills/rigor-type-oracle/references/01-oracle-commands.md +1 -1
- metadata +90 -3
|
@@ -11,7 +11,7 @@ module Rigor
|
|
|
11
11
|
# authors register more URIs through their manifests; user `.rbs` overlays register through the
|
|
12
12
|
# `%a{rigor:v1:hkt_register}` / `%a{rigor:v1:hkt_define}` annotations Slice 1 ships.
|
|
13
13
|
#
|
|
14
|
-
# Today's contents:
|
|
14
|
+
# Today's contents (`csv::parsed[K]` and `csv::row[K]` are described at their bodies below):
|
|
15
15
|
#
|
|
16
16
|
# - `json::value[K]` — the recursive sum stdlib's `JSON.parse` returns. Body:
|
|
17
17
|
#
|
|
@@ -137,22 +137,9 @@ module Rigor
|
|
|
137
137
|
)
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
-
#
|
|
141
|
-
#
|
|
142
|
-
#
|
|
143
|
-
# `RbsDispatch.try_dispatch` so a known stdlib method
|
|
144
|
-
# (`JSON.parse`, `JSON.parse!`) gets the reduced HKT
|
|
145
|
-
# type instead of the upstream rbs gem's `untyped`
|
|
146
|
-
# return. The annotation-based `%a{rigor:v1:return:
|
|
147
|
-
# App[...]}` path (parsed by
|
|
148
|
-
# `RbsExtended.parse_return_type_override`) is the
|
|
149
|
-
# general extension surface for user-authored sigs;
|
|
150
|
-
# this table is the Rigor-bundled shortcut for the
|
|
151
|
-
# handful of stdlib methods whose RBS declarations
|
|
152
|
-
# cannot be cleanly overridden via RBS overlay merging.
|
|
153
|
-
#
|
|
154
|
-
# Each entry maps to a hash with `:uri` and `:args`
|
|
155
|
-
# (an array of Ruby class names). The dispatcher
|
|
140
|
+
# A table entry maps to a hash with `:uri`, `:args`
|
|
141
|
+
# (an array of Ruby class names), `:discriminator` and
|
|
142
|
+
# `:post_reduce`. The dispatcher
|
|
156
143
|
# builds `Type::App.new(uri, args.map { Nominal })`,
|
|
157
144
|
# then reduces via the env's `hkt_registry` so the
|
|
158
145
|
# caller observes the unfolded form
|
|
@@ -196,6 +183,19 @@ module Rigor
|
|
|
196
183
|
}.freeze
|
|
197
184
|
private_constant :CSV_ROW_SPEC
|
|
198
185
|
|
|
186
|
+
# ADR-20 slice 3 — hardcoded `(class_name, method_name,
|
|
187
|
+
# kind) => HKT application` table consulted by the
|
|
188
|
+
# dispatcher's new HKT-builtin tier. Sits ABOVE
|
|
189
|
+
# `RbsDispatch.try_dispatch` so a known stdlib method
|
|
190
|
+
# (`JSON.parse`, `JSON.parse!`) gets the reduced HKT
|
|
191
|
+
# type instead of the upstream rbs gem's `untyped`
|
|
192
|
+
# return. The annotation-based `%a{rigor:v1:return:
|
|
193
|
+
# App[...]}` path (parsed by
|
|
194
|
+
# `RbsExtended.parse_return_type_override`) is the
|
|
195
|
+
# general extension surface for user-authored sigs;
|
|
196
|
+
# this table is the Rigor-bundled shortcut for the
|
|
197
|
+
# handful of stdlib methods whose RBS declarations
|
|
198
|
+
# cannot be cleanly overridden via RBS overlay merging.
|
|
199
199
|
METHOD_RETURN_OVERRIDES = {
|
|
200
200
|
# JSON — stdlib's `json` library. Upstream rbs declares
|
|
201
201
|
# `(string, ?options) -> untyped`; the HKT-builtin tier
|
|
@@ -18,8 +18,8 @@ module Rigor
|
|
|
18
18
|
# - The `rigor:v1:return:` RBS::Extended directive
|
|
19
19
|
# ([`Rigor::RbsExtended.read_return_type_override`](../rbs_extended.rb)), which overrides
|
|
20
20
|
# a method's RBS-declared return type with a refinement carrier.
|
|
21
|
-
# -
|
|
22
|
-
# (`param:`, `assert: x is non-empty-string`, …)
|
|
21
|
+
# - The other `RBS::Extended` directives that accept a refinement name in a type position
|
|
22
|
+
# (`param:`, `assert: x is non-empty-string`, …), which parse through `parse(payload)`.
|
|
23
23
|
# - The display side: `Type::Difference#describe` already recognises the same shapes and
|
|
24
24
|
# prints the kebab-case spelling without consulting the registry.
|
|
25
25
|
#
|
|
@@ -444,11 +444,7 @@ module Rigor
|
|
|
444
444
|
members << following
|
|
445
445
|
end
|
|
446
446
|
|
|
447
|
-
|
|
448
|
-
# mutation inside the loop, so it folds the
|
|
449
|
-
# `size == 1` guard to a constant; the loop body
|
|
450
|
-
# actually grows the tuple, so the guard is real.
|
|
451
|
-
members.size == 1 ? first : TypeNode::Union.new(nodes: members) # rigor:disable flow.always-truthy-condition
|
|
447
|
+
members.size == 1 ? first : TypeNode::Union.new(nodes: members)
|
|
452
448
|
end
|
|
453
449
|
|
|
454
450
|
def parse_single_type_arg_ast
|
|
@@ -459,13 +455,9 @@ module Rigor
|
|
|
459
455
|
elsif (literal = @scanner.scan(SIGNED_INT))
|
|
460
456
|
TypeNode::IntegerLiteral.new(value: Integer(literal))
|
|
461
457
|
elsif @scanner.scan(SYMBOL_LITERAL)
|
|
462
|
-
|
|
463
|
-
# (Ruby behaviour); upstream RBS shim only declares the
|
|
464
|
-
# positional-capture (Integer) overload, so the
|
|
465
|
-
# argument-type-mismatch diagnostic is suppressed.
|
|
466
|
-
TypeNode::SymbolLiteral.new(value: @scanner[:value].to_sym) # rigor:disable argument-type-mismatch
|
|
458
|
+
TypeNode::SymbolLiteral.new(value: @scanner[:value].to_sym)
|
|
467
459
|
elsif @scanner.scan(STRING_LITERAL)
|
|
468
|
-
TypeNode::StringLiteral.new(value: @scanner[:value])
|
|
460
|
+
TypeNode::StringLiteral.new(value: @scanner[:value])
|
|
469
461
|
else
|
|
470
462
|
parse_type_ast
|
|
471
463
|
end
|
|
@@ -494,8 +486,8 @@ module Rigor
|
|
|
494
486
|
end
|
|
495
487
|
|
|
496
488
|
# Returns a {TypeNode::RangeLiteral} when the scanner sits on a Ruby range literal, `nil`
|
|
497
|
-
# (
|
|
498
|
-
# `nil` endpoint; the two spellings denote the same range.
|
|
489
|
+
# otherwise (a bare `..` with no endpoint is consumed, then rejected). `nil` and an absent
|
|
490
|
+
# endpoint both become Ruby's `nil` endpoint; the two spellings denote the same range.
|
|
499
491
|
def scan_range_literal
|
|
500
492
|
return nil unless @scanner.scan(RANGE_LITERAL)
|
|
501
493
|
|
|
@@ -562,7 +554,7 @@ module Rigor
|
|
|
562
554
|
end
|
|
563
555
|
|
|
564
556
|
# ADR-13 follow-up — every leaf-literal AST node (`IntegerLiteral` / `SymbolLiteral` /
|
|
565
|
-
# `StringLiteral`) carries a Ruby value that lifts directly to a `Constant<value>`
|
|
557
|
+
# `StringLiteral` / `RangeLiteral`) carries a Ruby value that lifts directly to a `Constant<value>`
|
|
566
558
|
# carrier through the same helper.
|
|
567
559
|
LITERAL_AST_NODES = [
|
|
568
560
|
TypeNode::IntegerLiteral, TypeNode::SymbolLiteral, TypeNode::StringLiteral, TypeNode::RangeLiteral
|
|
@@ -5,8 +5,8 @@ require_relative "../type"
|
|
|
5
5
|
module Rigor
|
|
6
6
|
module Builtins
|
|
7
7
|
# Maps a curated table of canonical regex sub-patterns onto the imported refinement
|
|
8
|
-
# carriers Rigor already ships (`decimal-int-string`, `
|
|
9
|
-
# `
|
|
8
|
+
# carriers Rigor already ships (`decimal-int-string`, `lowercase-string`,
|
|
9
|
+
# `uppercase-string`, `numeric-string`, and `non-empty-string`). See
|
|
10
10
|
# `docs/type-specification/imported-built-in-types.md` for the registry the refinements
|
|
11
11
|
# come from.
|
|
12
12
|
#
|
|
@@ -31,7 +31,7 @@ module Rigor
|
|
|
31
31
|
# conventional `0x` / `0o` prefix, but a bare digit class like `[0-9a-fA-F]+` matches "ff" —
|
|
32
32
|
# a string with no prefix at all. Mapping a matched digit run to a refinement its own
|
|
33
33
|
# predicate rejects is unsound (worse than the plain `String` it replaces), so these rows
|
|
34
|
-
# drop to `non-empty-string`: the `+` / `{n,}` (n >= 1) quantifier already guarantees the
|
|
34
|
+
# drop to `non-empty-string`: the `+` / `{n}` / `{n,m}` (n >= 1) quantifier already guarantees the
|
|
35
35
|
# captured run is never empty, and that much is true regardless of prefix.
|
|
36
36
|
#
|
|
37
37
|
# Anything outside the table returns `nil` so the calling narrowing site falls back to
|
|
@@ -25,9 +25,10 @@ module Rigor
|
|
|
25
25
|
# `Singleton[Kernel]` receiver) AND the instance-receiver shape (an implicit-self call
|
|
26
26
|
# like `__dir__` inside any class body, or `obj.__dir__` on an instance).
|
|
27
27
|
# - `kind: :singleton` / `kind: :instance` restrict the match to one of the two shapes.
|
|
28
|
-
# - The handler is called with `(arg_types)` so
|
|
29
|
-
#
|
|
30
|
-
# `
|
|
28
|
+
# - The handler is called with `(arg_types, context)` so an entry can refine based on argument
|
|
29
|
+
# types (as the `IO.read` / `File.read` entries do, keying on whether a length is given).
|
|
30
|
+
# `context` is the dispatch's `MethodDispatcher::CallContext`, or nil when the caller has none;
|
|
31
|
+
# the zero-start slice entries read its receiver, call node and environment.
|
|
31
32
|
#
|
|
32
33
|
# The override fires ABOVE RBS dispatch — if RBS would have returned a wider type
|
|
33
34
|
# (`String?` for `Kernel#__dir__`), the override returns the refined union
|
|
@@ -49,7 +50,7 @@ module Rigor
|
|
|
49
50
|
# in, or `nil` when the file is invalid / not available (typically `-e` and similar
|
|
50
51
|
# one-liner contexts). When non-nil the value is always a filesystem-canonical path —
|
|
51
52
|
# never the empty string — so `non-empty-string` is exact.
|
|
52
|
-
KERNEL_DIR = ->(_arg_types) { NON_EMPTY_STRING_OR_NIL }
|
|
53
|
+
KERNEL_DIR = ->(_arg_types, _context) { NON_EMPTY_STRING_OR_NIL }
|
|
53
54
|
private_constant :KERNEL_DIR
|
|
54
55
|
|
|
55
56
|
# `File.expand_path(path, ?dir_string)` always returns an absolute path string. Even
|
|
@@ -63,7 +64,7 @@ module Rigor
|
|
|
63
64
|
#
|
|
64
65
|
# `File.basename` is intentionally NOT refined: it returns `""` for
|
|
65
66
|
# `File.basename("")`, so `non-empty-string` would be unsound.
|
|
66
|
-
FILE_NON_EMPTY = ->(_arg_types) { NON_EMPTY_STRING }
|
|
67
|
+
FILE_NON_EMPTY = ->(_arg_types, _context) { NON_EMPTY_STRING }
|
|
67
68
|
private_constant :FILE_NON_EMPTY
|
|
68
69
|
|
|
69
70
|
STRING_NOMINAL = Type::Combinator.nominal_of("String").freeze
|
|
@@ -77,12 +78,131 @@ module Rigor
|
|
|
77
78
|
# sites). The refinement drops the nil exactly when no positional length is present; a
|
|
78
79
|
# keyword-only trailing hash (`mode:`, `encoding:`) is not a length. Same family as the
|
|
79
80
|
# staged upstream signature fixes (#159).
|
|
80
|
-
IO_READ_NO_LENGTH = lambda do |arg_types|
|
|
81
|
+
IO_READ_NO_LENGTH = lambda do |arg_types, _context|
|
|
81
82
|
positional = arg_types.grep_v(Type::HashShape)
|
|
82
83
|
positional.size <= 1 ? STRING_NOMINAL : nil
|
|
83
84
|
end
|
|
84
85
|
private_constant :IO_READ_NO_LENGTH
|
|
85
86
|
|
|
87
|
+
# Issue #3326 — `Array#[]` / `Array#slice` / `String#[]` / `String#slice` with a range declare
|
|
88
|
+
# `-> Array[Elem]?` / `-> String?`, because a range whose start lies past the end answers nil
|
|
89
|
+
# (`[1][5..]`). A start of `0` (or a beginless range, whose start is `0`) is never past the end,
|
|
90
|
+
# so the read answers the receiver's own type: `[][0...-1]` is `[]`, `""[0..]` is `""`. The same
|
|
91
|
+
# holds for the `(0, length)` form when the length is statically non-negative (`[][0, 2]` is `[]`,
|
|
92
|
+
# but `[1][0, -1]` is nil). Any other start keeps the declared nilable answer.
|
|
93
|
+
ZERO_START_SLICE = lambda do |arg_types, context|
|
|
94
|
+
ZeroStartSlice.answer(arg_types, context)
|
|
95
|
+
end
|
|
96
|
+
private_constant :ZERO_START_SLICE
|
|
97
|
+
|
|
98
|
+
# The predicate behind {ZERO_START_SLICE}. The start is read from the argument TYPE when it is a
|
|
99
|
+
# `Constant` range (`0..`, a `R = (0..)` constant, `z..` with `z = 0`), and otherwise from the
|
|
100
|
+
# call's own argument NODE, because a range with a non-constant end (`0..i`, `..n`) types as
|
|
101
|
+
# `Range[Integer]` and has lost its start. The node is trusted only when it is the call's own
|
|
102
|
+
# argument list (same selector, same arity); a `send(:[], …)` re-dispatch reads types only.
|
|
103
|
+
module ZeroStartSlice
|
|
104
|
+
module_function
|
|
105
|
+
|
|
106
|
+
def answer(arg_types, context)
|
|
107
|
+
receiver = context&.receiver
|
|
108
|
+
class_name = receiver_class_name(receiver)
|
|
109
|
+
return nil if class_name.nil?
|
|
110
|
+
return nil unless zero_start?(arg_types, context.call_node, context.method_name)
|
|
111
|
+
return nil if project_patched?(context.environment, class_name, context.method_name)
|
|
112
|
+
|
|
113
|
+
non_nil_answer(receiver)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Core `Array[E]`, `String` and a `Tuple` (which reaches this table only when `ShapeDispatch`
|
|
117
|
+
# declined it, so for a range whose end is not a constant). A raw `Array` (no type argument) keeps
|
|
118
|
+
# the RBS answer, whose rendering of the element differs.
|
|
119
|
+
def receiver_class_name(receiver)
|
|
120
|
+
case receiver
|
|
121
|
+
when Type::Tuple then "Array"
|
|
122
|
+
when Type::Nominal
|
|
123
|
+
case receiver.class_name
|
|
124
|
+
when "Array" then "Array" if receiver.type_args.size == 1
|
|
125
|
+
when "String" then "String" if receiver.type_args.empty?
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
UNTYPED_ARRAY = Type::Combinator.nominal_of("Array", type_args: [Type::Combinator.untyped]).freeze
|
|
131
|
+
|
|
132
|
+
# The declared answer without its `nil`, and nothing else changed: the receiver's own type for
|
|
133
|
+
# `Array[E]` and `String`; for a tuple, the `Array[E]` RBS projects it to (`Array[1 | 2]` for
|
|
134
|
+
# `[1, 2]`, `Array[untyped]` for the empty tuple, whose descriptor carries no element).
|
|
135
|
+
def non_nil_answer(receiver)
|
|
136
|
+
return receiver unless receiver.is_a?(Type::Tuple)
|
|
137
|
+
return UNTYPED_ARRAY if receiver.elements.empty?
|
|
138
|
+
|
|
139
|
+
Type::Combinator.nominal_of("Array", type_args: [Type::Combinator.union(*receiver.elements)])
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def zero_start?(arg_types, call_node, method_name)
|
|
143
|
+
case arg_types.size
|
|
144
|
+
when 1
|
|
145
|
+
zero_start_range_type?(arg_types.first) ||
|
|
146
|
+
zero_start_range_node?(own_argument(call_node, method_name, 1))
|
|
147
|
+
when 2
|
|
148
|
+
zero_integer?(arg_types.first) && non_negative_integer?(arg_types.last)
|
|
149
|
+
else false
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def zero_start_range_type?(type)
|
|
154
|
+
return false unless type.is_a?(Type::Constant)
|
|
155
|
+
|
|
156
|
+
value = type.value
|
|
157
|
+
value.is_a?(Range) && zero_or_nil?(value.begin)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def zero_start_range_node?(node)
|
|
161
|
+
return false unless node.is_a?(Prism::RangeNode)
|
|
162
|
+
|
|
163
|
+
left = node.left
|
|
164
|
+
left.nil? || (left.is_a?(Prism::IntegerNode) && left.value.zero?)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# The call node's only positional argument, when the dispatch is that node's own call: same
|
|
168
|
+
# selector and the same argument count. Anything else (a `send` re-dispatch, a splat, a node
|
|
169
|
+
# that is not a call) answers nil.
|
|
170
|
+
def own_argument(call_node, method_name, arity)
|
|
171
|
+
return nil unless call_node.is_a?(Prism::CallNode) && call_node.name == method_name
|
|
172
|
+
|
|
173
|
+
arguments = call_node.arguments&.arguments
|
|
174
|
+
return nil if arguments.nil? || arguments.size != arity
|
|
175
|
+
|
|
176
|
+
arguments.first
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def zero_or_nil?(value)
|
|
180
|
+
value.nil? || (value.is_a?(Integer) && value.zero?)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def zero_integer?(type)
|
|
184
|
+
type.is_a?(Type::Constant) && type.value.is_a?(Integer) && type.value.zero?
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def non_negative_integer?(type)
|
|
188
|
+
case type
|
|
189
|
+
when Type::Constant then type.value.is_a?(Integer) && !type.value.negative?
|
|
190
|
+
when Type::IntegerRange then type.min.is_a?(Integer) && !type.min.negative?
|
|
191
|
+
else false
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# A `pre_eval:` reopening of `Array` / `String` that redefines the read means the method that
|
|
196
|
+
# runs is not core's, so the core guarantee does not hold (ADR-17).
|
|
197
|
+
def project_patched?(environment, class_name, method_name)
|
|
198
|
+
patched = environment&.project_patched_methods
|
|
199
|
+
return false if patched.nil? || patched.empty?
|
|
200
|
+
|
|
201
|
+
!patched.lookup(class_name: class_name, method_name: method_name, kind: :instance).nil?
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
private_constant :ZeroStartSlice
|
|
205
|
+
|
|
86
206
|
# Frozen ((owner_class_name, method_name, kind) => handler) table. The kind tag is
|
|
87
207
|
# `:both`, `:singleton`, or `:instance`. New entries SHOULD prefer `:both` unless the
|
|
88
208
|
# singleton- and instance-side shapes genuinely differ.
|
|
@@ -91,7 +211,11 @@ module Rigor
|
|
|
91
211
|
["File", :expand_path, :singleton] => FILE_NON_EMPTY,
|
|
92
212
|
["File", :dirname, :singleton] => FILE_NON_EMPTY,
|
|
93
213
|
["IO", :read, :singleton] => IO_READ_NO_LENGTH,
|
|
94
|
-
["File", :read, :singleton] => IO_READ_NO_LENGTH
|
|
214
|
+
["File", :read, :singleton] => IO_READ_NO_LENGTH,
|
|
215
|
+
["Array", :[], :instance] => ZERO_START_SLICE,
|
|
216
|
+
["Array", :slice, :instance] => ZERO_START_SLICE,
|
|
217
|
+
["String", :[], :instance] => ZERO_START_SLICE,
|
|
218
|
+
["String", :slice, :instance] => ZERO_START_SLICE
|
|
95
219
|
}.freeze
|
|
96
220
|
Ractor.make_shareable(OVERRIDES)
|
|
97
221
|
private_constant :OVERRIDES
|
|
@@ -99,27 +223,27 @@ module Rigor
|
|
|
99
223
|
# Looks up a refined return type for the given call.
|
|
100
224
|
#
|
|
101
225
|
# @param owner_class_name — the class on which the method is defined
|
|
102
|
-
# (e.g., `"Kernel"`).
|
|
103
|
-
#
|
|
104
|
-
# entries whose owner is currently in the table.
|
|
226
|
+
# (e.g., `"Kernel"`). A `nil` owner (the caller has not resolved one) returns `nil`; the
|
|
227
|
+
# dispatcher resolves candidates through {owners_for} first.
|
|
105
228
|
# @param kind — one of `:singleton`, `:instance`. The caller passes the shape of
|
|
106
229
|
# the actual call site; the table stores `:both` for entries that match either.
|
|
107
230
|
# @param arg_types — positional argument types. Forwarded to the
|
|
108
|
-
# handler so
|
|
231
|
+
# handler so an entry can discriminate on argument shape.
|
|
232
|
+
# @param context — the dispatch's `CallContext`, forwarded to the handler; nil when absent.
|
|
109
233
|
# @return the refined return type, or `nil` when no override
|
|
110
234
|
# matches.
|
|
111
|
-
def self.lookup(owner_class_name:, method_name:, kind:, arg_types: [])
|
|
235
|
+
def self.lookup(owner_class_name:, method_name:, kind:, arg_types: [], context: nil)
|
|
112
236
|
return nil if owner_class_name.nil?
|
|
113
237
|
|
|
114
238
|
method_sym = method_name.to_sym
|
|
115
239
|
handler = OVERRIDES[[owner_class_name, method_sym, :both]] ||
|
|
116
240
|
OVERRIDES[[owner_class_name, method_sym, kind]]
|
|
117
|
-
handler&.call(arg_types)
|
|
241
|
+
handler&.call(arg_types, context)
|
|
118
242
|
end
|
|
119
243
|
|
|
120
244
|
# Indexed view by `(method_name, kind)` — used by the dispatcher when the receiver's
|
|
121
245
|
# owner is not yet resolved but the method name alone uniquely identifies a stdlib
|
|
122
|
-
# override (
|
|
246
|
+
# override (e.g. `__dir__` → Kernel). The table is small and the index rebuild cost
|
|
123
247
|
# trivial, but precomputing keeps `dispatch`'s hot path free of an O(n) scan.
|
|
124
248
|
OWNERS_BY_METHOD = OVERRIDES.each_with_object({}) do |((owner, mname, _kind), _h), acc|
|
|
125
249
|
acc[mname] ||= []
|
|
@@ -128,14 +252,14 @@ module Rigor
|
|
|
128
252
|
Ractor.make_shareable(OWNERS_BY_METHOD)
|
|
129
253
|
private_constant :OWNERS_BY_METHOD
|
|
130
254
|
|
|
131
|
-
#
|
|
132
|
-
#
|
|
255
|
+
# The miss result of {owners_for}: the miss case is overwhelmingly common, so share one
|
|
256
|
+
# frozen empty array instead of allocating a fresh `[]` per non-refined method.
|
|
133
257
|
NO_OWNERS = [].freeze
|
|
134
258
|
private_constant :NO_OWNERS
|
|
135
259
|
|
|
136
|
-
#
|
|
137
|
-
#
|
|
138
|
-
#
|
|
260
|
+
# @return the candidate owner class names for a bare method-name
|
|
261
|
+
# lookup. Empty when no override names this method. Consulted on every dispatch
|
|
262
|
+
# (`MethodDispatcher::StaticRefinement.try_dispatch`).
|
|
139
263
|
def self.owners_for(method_name)
|
|
140
264
|
OWNERS_BY_METHOD[method_name.to_sym] || NO_OWNERS
|
|
141
265
|
end
|
|
@@ -6,6 +6,7 @@ require "zlib"
|
|
|
6
6
|
|
|
7
7
|
require_relative "engine_source"
|
|
8
8
|
require_relative "store"
|
|
9
|
+
require_relative "rbs_descriptor"
|
|
9
10
|
require_relative "../analysis/shadow_harness"
|
|
10
11
|
require_relative "../analysis/run_cache_key"
|
|
11
12
|
require_relative "../analysis/runner/run_level_facts"
|
|
@@ -427,20 +428,32 @@ module Rigor
|
|
|
427
428
|
private_class_method :dependency_source_parts
|
|
428
429
|
|
|
429
430
|
# The parts read off the project beside its configuration, in the order the fingerprint has always joined them:
|
|
430
|
-
# the extra signature roots, the `dependencies.source_inference` gems, and
|
|
431
|
+
# the extra signature roots, the `dependencies.source_inference` gems, and the `rbs collection` parts.
|
|
431
432
|
def self.project_input_parts(configuration)
|
|
432
|
-
extra_signature_parts(configuration) + dependency_source_parts(configuration) +
|
|
433
|
-
collection_setup_hint_parts(configuration)
|
|
433
|
+
extra_signature_parts(configuration) + dependency_source_parts(configuration) + collection_parts(configuration)
|
|
434
434
|
end
|
|
435
435
|
private_class_method :project_input_parts
|
|
436
436
|
|
|
437
437
|
# Issue #3030 — the `rbs.coverage.collection-not-installed` hint, a run-level row read off the working directory
|
|
438
438
|
# that no other part covers. No part without a hint, so every other project's fingerprint is as it was.
|
|
439
|
-
|
|
439
|
+
#
|
|
440
|
+
# Issue #3468 — the installed `rbs collection` gem directories the lockfile lists: which exist (an empty one
|
|
441
|
+
# still decides the ADR-72 overlays and the missing-gem row) and what their `.rbs` files hold. The
|
|
442
|
+
# `rbs_collection:` part digests the lockfile alone, so an edit in place to an installed file, or a file or gem
|
|
443
|
+
# directory added or removed, under an unchanged lockfile replayed the old answers. The directories are the
|
|
444
|
+
# lockfile's, under its own `path:`, before the environment's skip lists ({Environment}), so a skipped gem's edit
|
|
445
|
+
# drops the snapshot too: a needless rebuild, never a stale answer. Each file folds in through
|
|
446
|
+
# {RbsDescriptor.signature_file_digest}, the per-file digest the plain run cache keys the same files by, so an
|
|
447
|
+
# unreadable one is a marker rather than a raise. No part for a project without an installed collection.
|
|
448
|
+
def self.collection_parts(configuration)
|
|
440
449
|
hint = Analysis::RunCacheKey.collection_setup_hint(configuration)
|
|
441
|
-
|
|
450
|
+
dirs = Environment::RbsCollectionDiscovery.discover(lockfile_path: configuration.rbs_collection_lockfile,
|
|
451
|
+
auto_detect: configuration.rbs_collection_auto_detect)
|
|
452
|
+
dirs = dirs.map(&:to_s).sort
|
|
453
|
+
[("rbs-collection-hint:#{hint}" if hint),
|
|
454
|
+
("collection-sig:#{dirs.join("\n")}:#{digest_signature_paths(dirs)}" unless dirs.empty?)].compact
|
|
442
455
|
end
|
|
443
|
-
private_class_method :
|
|
456
|
+
private_class_method :collection_parts
|
|
444
457
|
|
|
445
458
|
def self.digest_file_if_present(path)
|
|
446
459
|
path = path&.to_s
|
|
@@ -477,14 +490,14 @@ module Rigor
|
|
|
477
490
|
|
|
478
491
|
# Content-digest every `.rbs` under the configured signature paths (sorted for determinism) so a project
|
|
479
492
|
# RBS edit invalidates the snapshot. Sig trees are small; content (not mtime) keeps it stable across
|
|
480
|
-
# checkouts.
|
|
493
|
+
# checkouts. An unreadable file folds in a stable marker instead of raising (#3002).
|
|
481
494
|
def self.digest_signature_paths(signature_paths)
|
|
482
495
|
globbed = Array(signature_paths).flat_map do |entry|
|
|
483
496
|
File.directory?(entry) ? RootedGlob.glob(entry, "**/*.rbs") : [entry]
|
|
484
497
|
end
|
|
485
498
|
files = globbed.select { |path| File.file?(path) }.sort
|
|
486
499
|
digest = Digest::SHA256.new
|
|
487
|
-
files.each { |path| digest << path << "\0" <<
|
|
500
|
+
files.each { |path| digest << path << "\0" << RbsDescriptor.signature_file_digest(path) << "\0" }
|
|
488
501
|
digest.hexdigest
|
|
489
502
|
end
|
|
490
503
|
private_class_method :digest_signature_paths
|
|
@@ -6,6 +6,7 @@ require_relative "descriptor"
|
|
|
6
6
|
require_relative "engine_source"
|
|
7
7
|
require_relative "file_digest"
|
|
8
8
|
require_relative "../rooted_glob"
|
|
9
|
+
require_relative "../environment/unreadable_signature"
|
|
9
10
|
|
|
10
11
|
module Rigor
|
|
11
12
|
module Cache
|
|
@@ -197,7 +198,7 @@ module Rigor
|
|
|
197
198
|
next [] unless root.directory?
|
|
198
199
|
|
|
199
200
|
RootedGlob.glob(root, "**/*.rbs").map do |path|
|
|
200
|
-
digest =
|
|
201
|
+
digest = signature_file_digest(path)
|
|
201
202
|
if comparator == :stat
|
|
202
203
|
Descriptor::FileEntry.stat(path: path, digest: digest)
|
|
203
204
|
else
|
|
@@ -207,6 +208,22 @@ module Rigor
|
|
|
207
208
|
end
|
|
208
209
|
end
|
|
209
210
|
|
|
211
|
+
# Issue #3002 — the value a signature file's row carries when the file cannot be read (`chmod 000`, a
|
|
212
|
+
# directory named `*.rbs`, a file removed after the glob, a symlink loop — #3469). Not a hex digest, so it
|
|
213
|
+
# never equals a readable file's; the row therefore moves the env key, and validates stale, once the file can
|
|
214
|
+
# be read again.
|
|
215
|
+
UNREADABLE_DIGEST = "unreadable"
|
|
216
|
+
|
|
217
|
+
# A signature file's content digest, or {UNREADABLE_DIGEST} for a file the RBS loader skips as unreadable
|
|
218
|
+
# (both rescue {Environment::UnreadableSignature::ERRORS}). The cached run then loads what a `--no-cache`
|
|
219
|
+
# run loads instead of crashing on the digest. Also the per-file digest of
|
|
220
|
+
# {IncrementalSnapshot.fingerprint}'s `sig:`, `core:` and `bundle-sig` parts.
|
|
221
|
+
def self.signature_file_digest(path)
|
|
222
|
+
FileDigest.hexdigest(path)
|
|
223
|
+
rescue *Environment::UnreadableSignature::ERRORS
|
|
224
|
+
UNREADABLE_DIGEST
|
|
225
|
+
end
|
|
226
|
+
|
|
210
227
|
# Issue #979 — the directory-LISTING rows for the signature roots, one {Descriptor::GlobEntry} per
|
|
211
228
|
# root over `**/*.rbs`. {.file_entries} answers "did any signature file I read change", which is a
|
|
212
229
|
# question only about files that existed when the run recorded its dependencies; a `sig/roles.rbs`
|
|
@@ -55,9 +55,18 @@ module Rigor
|
|
|
55
55
|
@out.puts(" precise: #{p}#{pct(p, g)}")
|
|
56
56
|
@out.puts(" dynamic (opaque): #{o}#{pct(o, g)}")
|
|
57
57
|
@out.puts(" precision ratio: #{(report.precision_ratio * 100).round(2)}%")
|
|
58
|
+
render_text_call_sites(report)
|
|
58
59
|
@out.puts
|
|
59
60
|
end
|
|
60
61
|
|
|
62
|
+
# #3315 — the call-site tally `make coverage` ratchets.
|
|
63
|
+
def render_text_call_sites(report)
|
|
64
|
+
calls = report.call_sites
|
|
65
|
+
dynamic = report.dynamic_call_sites
|
|
66
|
+
@out.puts(" call sites: #{calls}")
|
|
67
|
+
@out.puts(" dynamic call sites: #{dynamic}#{pct(dynamic, calls)}")
|
|
68
|
+
end
|
|
69
|
+
|
|
61
70
|
def render_text_tier_table(report)
|
|
62
71
|
@out.puts("Tier breakdown:")
|
|
63
72
|
g = report.grand_total
|
|
@@ -119,7 +128,10 @@ module Rigor
|
|
|
119
128
|
dynamic_opaque_count: report.opaque_count,
|
|
120
129
|
dynamic_opaque_ratio: ratio_f(report.opaque_ratio),
|
|
121
130
|
dynamic_specific_count: dsc,
|
|
122
|
-
dynamic_specific_ratio: ratio_f(dsc.fdiv(g.nonzero? || 1))
|
|
131
|
+
dynamic_specific_ratio: ratio_f(dsc.fdiv(g.nonzero? || 1)),
|
|
132
|
+
call_sites: report.call_sites,
|
|
133
|
+
dynamic_call_count: report.dynamic_call_sites,
|
|
134
|
+
dynamic_call_ratio: ratio_f(report.dynamic_call_ratio)
|
|
123
135
|
}
|
|
124
136
|
end
|
|
125
137
|
|
|
@@ -140,6 +152,8 @@ module Rigor
|
|
|
140
152
|
precise_ratio: ratio_f(r.precision_ratio),
|
|
141
153
|
dynamic_opaque_count: r.opaque_count,
|
|
142
154
|
dynamic_opaque_ratio: ratio_f(r.opaque_ratio),
|
|
155
|
+
call_sites: r.call_sites,
|
|
156
|
+
dynamic_call_count: r.dynamic_call_sites,
|
|
143
157
|
by_tier: tier_payload(r.total) { |tier| r.tier_counts.fetch(tier, 0) }
|
|
144
158
|
}
|
|
145
159
|
end
|
|
@@ -31,6 +31,18 @@ module Rigor
|
|
|
31
31
|
total.opaque_ratio
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def call_sites
|
|
35
|
+
total.call_sites
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def dynamic_call_sites
|
|
39
|
+
total.dynamic_call_sites
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def dynamic_call_ratio
|
|
43
|
+
total.dynamic_call_ratio
|
|
44
|
+
end
|
|
45
|
+
|
|
34
46
|
def tier_count(tier)
|
|
35
47
|
total.tier_counts.fetch(tier, 0)
|
|
36
48
|
end
|
|
@@ -45,12 +57,16 @@ module Rigor
|
|
|
45
57
|
@parse_errors = []
|
|
46
58
|
@total_total = 0
|
|
47
59
|
@total_tier_counts = Inference::PrecisionScanner::TIERS.to_h { |t| [t, 0] }
|
|
60
|
+
@total_call_sites = 0
|
|
61
|
+
@total_dynamic_call_sites = 0
|
|
48
62
|
end
|
|
49
63
|
|
|
50
64
|
def absorb(path, file_result)
|
|
51
65
|
@per_file << { file: path, result: file_result }
|
|
52
66
|
@total_total += file_result.total
|
|
53
67
|
file_result.tier_counts.each { |tier, n| @total_tier_counts[tier] += n }
|
|
68
|
+
@total_call_sites += file_result.call_sites
|
|
69
|
+
@total_dynamic_call_sites += file_result.dynamic_call_sites
|
|
54
70
|
end
|
|
55
71
|
|
|
56
72
|
def record_parse_error(path, errors)
|
|
@@ -64,7 +80,9 @@ module Rigor
|
|
|
64
80
|
per_file: @per_file,
|
|
65
81
|
total: Inference::PrecisionScanner::FileResult.new(
|
|
66
82
|
total: @total_total,
|
|
67
|
-
tier_counts: @total_tier_counts
|
|
83
|
+
tier_counts: @total_tier_counts,
|
|
84
|
+
call_sites: @total_call_sites,
|
|
85
|
+
dynamic_call_sites: @total_dynamic_call_sites
|
|
68
86
|
)
|
|
69
87
|
)
|
|
70
88
|
end
|
|
@@ -20,6 +20,7 @@ module Rigor
|
|
|
20
20
|
# checkstyle — Checkstyle XML, the broad lint-interchange format that
|
|
21
21
|
# reviewdog (`-f=checkstyle`) and Jenkins/etc. consume
|
|
22
22
|
# junit — JUnit XML, the test-report format many CI systems render
|
|
23
|
+
# teamcity — TeamCity inspection service messages (`##teamcity[…]`)
|
|
23
24
|
#
|
|
24
25
|
# Severity maps once per format from Rigor's `:error` / `:warning` / `:info`; the qualified rule
|
|
25
26
|
# (`<source_family>.<rule>` or the bare rule for the builtin family) is the stable identifier, nil only for the
|
|
@@ -65,8 +66,8 @@ module Rigor
|
|
|
65
66
|
SCHEMA = "https://json.schemastore.org/sarif-2.1.0.json"
|
|
66
67
|
INFORMATION_URI = "https://github.com/rigortype/rigor"
|
|
67
68
|
|
|
68
|
-
# SARIF
|
|
69
|
-
# findings).
|
|
69
|
+
# Rigor emits SARIF's `error` / `warning` / `note` levels; its `:info` is a `note` (the SARIF spelling for
|
|
70
|
+
# advisory findings).
|
|
70
71
|
LEVELS = { error: "error", warning: "warning", info: "note" }.freeze
|
|
71
72
|
|
|
72
73
|
def initialize(result)
|
|
@@ -158,11 +158,6 @@ module Rigor
|
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
# A key the rendered pages hand out for a document the gem does not carry (ADR-74 ships the manual and
|
|
162
|
-
# handbook; the ADR / specification / notes corpus and the repository trees stay out). The key is
|
|
163
|
-
# still answerable — it names a real path — so this routes rather than failing: a reader who followed
|
|
164
|
-
# `[ADR-103][adr/103-effect-labels]` out of `rigor docs` gets told where that document is, which is the
|
|
165
|
-
# whole point of handing them the key instead of a dead relative path or a `master` URL.
|
|
166
161
|
# Categories this command serves itself. A name that fails to resolve inside one of them is a typo,
|
|
167
162
|
# not an unpackaged document, and must reach the did-you-mean listing rather than be routed to a
|
|
168
163
|
# repository path that does not exist — `rigor docs list` and `rigor docs pathh` are the cases
|
|
@@ -170,6 +165,11 @@ module Rigor
|
|
|
170
165
|
PACKAGED_CATEGORIES = %w[manual handbook].freeze
|
|
171
166
|
private_constant :PACKAGED_CATEGORIES
|
|
172
167
|
|
|
168
|
+
# A key the rendered pages hand out for a document the gem does not carry (ADR-74 ships the manual and
|
|
169
|
+
# handbook; the ADR / specification / notes corpus and the repository trees stay out). The key is
|
|
170
|
+
# still answerable — it names a real path — so this routes rather than failing: a reader who followed
|
|
171
|
+
# `[ADR-103][adr/103-effect-labels]` out of `rigor docs` gets told where that document is, which is the
|
|
172
|
+
# whole point of handing them the key instead of a dead relative path or a `master` URL.
|
|
173
173
|
def unpackaged_doc(query)
|
|
174
174
|
return nil unless query.include?("/")
|
|
175
175
|
return nil if PACKAGED_CATEGORIES.include?(query.split("/").first)
|
|
@@ -29,8 +29,8 @@ module Rigor
|
|
|
29
29
|
# - `rigor effects {update,check,diff,explain}` — the committed **effect snapshot** and its drift
|
|
30
30
|
# gate, in {EffectsSnapshotCommand}.
|
|
31
31
|
#
|
|
32
|
-
# Neither emits a diagnostic nor enters `rigor check`'s stream;
|
|
33
|
-
# `check`
|
|
32
|
+
# Neither emits a diagnostic nor enters `rigor check`'s stream; a report that ran exits 0, and of the
|
|
33
|
+
# snapshot verbs only `check` exits 1 (on drift). A usage error exits 64 on either surface.
|
|
34
34
|
#
|
|
35
35
|
# The command turns collection on for its own run by loading the project's configuration and enabling
|
|
36
36
|
# an implicit `effects: {}` when the file carries no `effects:` block — the ad-hoc mode ADR-103 WD14
|
|
@@ -185,10 +185,6 @@ module Rigor
|
|
|
185
185
|
options
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
# Sequential and cache-backed, through the same ADR-45 whole-run result cache `rigor check` uses:
|
|
189
|
-
# the diagnostics entry serves the run and the #382 effects sidecar serves the collections, leaving
|
|
190
|
-
# only the fixpoint. Sequential is not a cache decision — the run-result cache declines pool mode —
|
|
191
|
-
# but a collecting run is pinned to the fork backend anyway, so `workers: 0` costs nothing here.
|
|
192
188
|
# #429 — the vocabulary, from the product rather than from a document the gem does not ship.
|
|
193
189
|
#
|
|
194
190
|
# Four configuration keys and two annotation forms all require typing an effect label, and until
|
|
@@ -241,6 +237,11 @@ module Rigor
|
|
|
241
237
|
# project does — still analyses it. Inside a project the argument is already under `paths:` and the
|
|
242
238
|
# union is the configured set unchanged.
|
|
243
239
|
#
|
|
240
|
+
# Sequential and cache-backed, through the same ADR-45 whole-run result cache `rigor check` uses:
|
|
241
|
+
# the diagnostics entry serves the run and the #382 effects sidecar serves the collections, leaving
|
|
242
|
+
# only the fixpoint. Sequential is not a cache decision — the run-result cache declines pool mode —
|
|
243
|
+
# but a collecting run is pinned to the fork backend anyway, so `workers: 0` costs nothing here.
|
|
244
|
+
#
|
|
244
245
|
# @return the table, and which
|
|
245
246
|
# file each unit was defined in — the map {EffectsReport} needs to answer a path argument.
|
|
246
247
|
def analyze(configuration, scope)
|