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
|
@@ -9,7 +9,7 @@ module Rigor
|
|
|
9
9
|
# nothing (negative edges — adding that symbol later must re-check the consumer).
|
|
10
10
|
#
|
|
11
11
|
# Thread-local and activated per `analyze_file` only when the runner opts in (`record_dependencies: true`);
|
|
12
|
-
# a normal run never activates it, so {active?} is a single
|
|
12
|
+
# a normal run never activates it, so {active?} is a single integer read and the instrumented `Scope`
|
|
13
13
|
# accessors pay nothing. Recording is purely observational — it never changes a diagnostic.
|
|
14
14
|
#
|
|
15
15
|
# Modelled on {Inference::BudgetTrace}: process-thread-local state, a cheap disabled fast path, and a
|
|
@@ -30,10 +30,8 @@ module Rigor
|
|
|
30
30
|
state.to_index(dependencies)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
# Per-build mutable accumulator
|
|
34
|
-
# `
|
|
35
|
-
# budget; the struct collects the same fields, narrows `absorb`'s branching, and yields one
|
|
36
|
-
# `Index.new(...)` call from `to_index`.
|
|
33
|
+
# Per-build mutable accumulator: collects each gem's outcome and yields one `Index.new(...)` call from
|
|
34
|
+
# `to_index`.
|
|
37
35
|
class BuildState
|
|
38
36
|
def initialize
|
|
39
37
|
@resolved = []
|
|
@@ -29,8 +29,7 @@ module Rigor
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# Unresolvable reasons. `:not_in_bundle` covers both the "RubyGems doesn't know this gem" case and the
|
|
32
|
-
# `LoadError`-style raise from `find_by_name`.
|
|
33
|
-
# introduced as the walker discovers them in slice 2b.
|
|
32
|
+
# `LoadError`-style raise from `find_by_name`. It is the only reason {VALID_REASONS} admits today.
|
|
34
33
|
Unresolvable = Data.define(:gem_name, :reason)
|
|
35
34
|
|
|
36
35
|
VALID_REASONS = %i[not_in_bundle].freeze
|
|
@@ -27,9 +27,9 @@ module Rigor
|
|
|
27
27
|
# only loads `.rb` files.
|
|
28
28
|
module Walker
|
|
29
29
|
# Top-level directories that MUST NOT participate in gem-source inference even when the user lists
|
|
30
|
-
# them under `roots:`. The check is case-insensitive against
|
|
31
|
-
# `spec/` / `test/` directories
|
|
32
|
-
# `lib/.../spec/`).
|
|
30
|
+
# them under `roots:`. The check is case-insensitive against each whole `roots:` entry, so a deeper
|
|
31
|
+
# entry such as `spec/support` is not matched; nested `spec/` / `test/` directories inside `lib/` are
|
|
32
|
+
# NOT filtered either (a few gems legitimately ship `lib/.../spec/`).
|
|
33
33
|
HARD_EXCLUDED_ROOTS = %w[spec test bin].freeze
|
|
34
34
|
|
|
35
35
|
# Walker outcome wrapping the harvested method catalog plus a budget-exceeded flag. ADR-10 slice 4
|
|
@@ -161,8 +161,8 @@ module Rigor
|
|
|
161
161
|
)
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
-
# Issue #1814 — the names the file binds by a constant write without declaring a class or module by them, or
|
|
165
|
-
#
|
|
164
|
+
# Issue #1814 — the names the file binds by a constant write without declaring a class or module by them, or the
|
|
165
|
+
# last segment alone where the walk cannot spell the owner Ruby binds. A bare write (`K = …`, `K ||= …`,
|
|
166
166
|
# `K += …`, a multiple-assignment target) binds the name under the lexical nesting of the `class` / `module`
|
|
167
167
|
# headers around it, which a block does not change (a `Module.new do … end` or `module_eval { … }` body assigns
|
|
168
168
|
# a constant in the lexical scope around it); `prefixes` holds every nesting the headers can denote, since a
|
|
@@ -170,12 +170,12 @@ module Rigor
|
|
|
170
170
|
# `W::Shared::Inner` or `Shared::Inner`), as the census spells a refine target. A write whose value is one of
|
|
171
171
|
# the class-creating shapes the project walk registers as a declaration (`Class.new`, `Module.new`,
|
|
172
172
|
# `Struct.new`, `Data.define`, a `.freeze` tail or a `K = K || …` guard stripped:
|
|
173
|
-
# {Inference::
|
|
174
|
-
# a normal row. Where the owner cannot be spelled the segment
|
|
175
|
-
# any key: a write under `class << …` (the singleton's), a path
|
|
176
|
-
# bind under an included module's `Wrap`; `self::K = …` in a block
|
|
177
|
-
# `const_set` with a literal name (`Object.const_set(:K, …)` binds
|
|
178
|
-
# binds that name. One pass over the tree; the rows are not touched.
|
|
173
|
+
# {Inference::DeclarationWalk::Rules.meta_new_rvalue}) declares a class, so
|
|
174
|
+
# `Point = Struct.new(:x); refine(Point)` keeps a normal row. Where the owner cannot be spelled the segment
|
|
175
|
+
# alone is recorded, which matches that segment of any key: a write under `class << …` (the singleton's), a path
|
|
176
|
+
# write that is not rooted (`Wrap::K = …` may bind under an included module's `Wrap`; `self::K = …` in a block
|
|
177
|
+
# binds under the block's `self`), and a `const_set` with a literal name (`Object.const_set(:K, …)` binds
|
|
178
|
+
# `::K`). A rooted path (`::Shared::K = …`) binds that name. One pass over the tree; the rows are not touched.
|
|
179
179
|
def collect_bound_constants(node, prefixes, harvest)
|
|
180
180
|
return unless node.is_a?(Prism::Node)
|
|
181
181
|
|
|
@@ -196,8 +196,8 @@ module Rigor
|
|
|
196
196
|
end
|
|
197
197
|
|
|
198
198
|
def declares_class?(write)
|
|
199
|
-
rvalue = Inference::
|
|
200
|
-
!rvalue.nil? && Inference::
|
|
199
|
+
rvalue = Inference::DeclarationWalk::Rules.meta_new_rvalue(write)
|
|
200
|
+
!rvalue.nil? && Inference::DeclarationWalk::Rules.meta_new_constant_rvalue?(rvalue)
|
|
201
201
|
end
|
|
202
202
|
|
|
203
203
|
# The nestings a `class` / `module` body may sit in, given the ones its header is written in: a bare header
|
|
@@ -244,13 +244,13 @@ module Rigor
|
|
|
244
244
|
|
|
245
245
|
name, value = node.arguments&.arguments
|
|
246
246
|
return unless name.is_a?(Prism::SymbolNode) || name.is_a?(Prism::StringNode)
|
|
247
|
-
return if value && Inference::
|
|
247
|
+
return if value && Inference::DeclarationWalk::Rules.meta_new_constant_rvalue?(value)
|
|
248
248
|
|
|
249
249
|
harvest.bound_segments << name.unescaped
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
# Walks a Prism subtree, accumulating method definitions under their qualified class name. Mirrors
|
|
253
|
-
# the shape of `Inference::ScopeIndexer#
|
|
253
|
+
# the shape of `Inference::ScopeIndexer#walk_methods_and_def_nodes` but stays decoupled from `Scope` because
|
|
254
254
|
# gem-source inference runs without a scope context.
|
|
255
255
|
def walk_node(node, qualified_prefix, in_singleton_class, harvest, budget)
|
|
256
256
|
return unless node.is_a?(Prism::Node)
|
|
@@ -606,7 +606,7 @@ module Rigor
|
|
|
606
606
|
|
|
607
607
|
# ADR-89 WD1 — the changed files whose ancestry / file-level dependents must STILL be re-checked: those
|
|
608
608
|
# not provably declaration-stable. A changed file is declaration-STABLE (its ancestry / file-level
|
|
609
|
-
# dependents skippable) when its current {ScopeIndexer
|
|
609
|
+
# dependents skippable) when its current {ScopeIndexer::DeclarationSignature} matches the one stored in
|
|
610
610
|
# the snapshot's seed bundle — i.e. its edit changed no method signature, visibility, ancestry, member
|
|
611
611
|
# layout, def line, or method existence, so every cross-file DECLARATION fact its dependents consume is
|
|
612
612
|
# unchanged. The signature reads code, not comments; the other half of stability — that no source-RBS
|
|
@@ -1968,9 +1968,9 @@ module Rigor
|
|
|
1968
1968
|
runner.synthetic_method_index&.surface_digest
|
|
1969
1969
|
end
|
|
1970
1970
|
|
|
1971
|
-
# The answer {#recheck} gives when {#
|
|
1972
|
-
# re-analysed every file. {#run_incremental} reads `rebaselined` so it
|
|
1973
|
-
# nor reports the run as warm.
|
|
1971
|
+
# The answer {#recheck} gives when {#discovery_moved?}, {#served_effects_stale?} or {#synthetic_surface_moved?}:
|
|
1972
|
+
# a full baseline, reported as a recheck that re-analysed every file. {#run_incremental} reads `rebaselined` so it
|
|
1973
|
+
# neither runs a second baseline nor reports the run as warm.
|
|
1974
1974
|
def rebaseline_recheck(changed, added, removed)
|
|
1975
1975
|
diagnostics = baseline
|
|
1976
1976
|
recheck_result(diagnostics, [changed, added, removed],
|
|
@@ -48,7 +48,7 @@ module Rigor
|
|
|
48
48
|
File.exist?(path) ? NOT_A_RUBY_FILE : NO_SUCH_PATH
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
# The
|
|
51
|
+
# The diagnostics for `bad` (from {unusable}). A bad path among valid ones is a warning that it was
|
|
52
52
|
# skipped; a bad path that leaves nothing to analyse is an error, so a lone typo is not masked.
|
|
53
53
|
def diagnostics(bad, any_files:)
|
|
54
54
|
severity = any_files ? :warning : :error
|
|
@@ -21,10 +21,10 @@ module Rigor
|
|
|
21
21
|
# (a) every ADR-9 fact-store publication `(plugin_id, name) -> value` (a producer/consumer fact such as
|
|
22
22
|
# `activerecord :model_index`, `dry-types :dry_type_aliases`),
|
|
23
23
|
# (b) every declared ADR-60 producer's computed value (`sorbet :catalog`, `actionpack :controller_index`),
|
|
24
|
-
# (c) each plugin's optional {Plugin::Base
|
|
25
|
-
# state that lives in neither (a) nor (b).
|
|
24
|
+
# (c) each plugin's optional `incremental_state_fingerprint` hook (not defined on {Plugin::Base}; a plugin
|
|
25
|
+
# opts in by defining it) — a hook for internal catalog state that lives in neither (a) nor (b).
|
|
26
26
|
#
|
|
27
|
-
# The digest rides the {Cache::IncrementalSnapshot} (schema 9); a warm recheck compares it and, on a
|
|
27
|
+
# The digest rides the {Cache::IncrementalSnapshot} (since schema 9); a warm recheck compares it and, on a
|
|
28
28
|
# mismatch, invalidates the snapshot and runs a full analysis (the conservative, sound direction).
|
|
29
29
|
#
|
|
30
30
|
# OPAQUE plugins: a plugin that CONTRIBUTES per-call types (`dynamic_return` / `narrowing_facts`) but
|
|
@@ -226,8 +226,8 @@ module Rigor
|
|
|
226
226
|
true
|
|
227
227
|
end
|
|
228
228
|
|
|
229
|
-
# Channel (c): the optional
|
|
230
|
-
# defines it (it has a surface).
|
|
229
|
+
# Channel (c): the optional `incremental_state_fingerprint` hook, probed with `respond_to?`. Returns true when
|
|
230
|
+
# the plugin defines it (it has a surface).
|
|
231
231
|
# rubocop:disable-next Naming/PredicateMethod -- reports has-surface AND appends parts (a side-effecting builder)
|
|
232
232
|
def collect_hook_part(plugin, id, parts, reasons)
|
|
233
233
|
return false unless plugin.respond_to?(:incremental_state_fingerprint)
|
|
@@ -241,7 +241,7 @@ module Rigor
|
|
|
241
241
|
Undecidable = Data.define(:fqn, :path, :line, :reason)
|
|
242
242
|
|
|
243
243
|
# @param root_fqns — declarations that are entry points regardless of who references
|
|
244
|
-
# them (config-declared globs
|
|
244
|
+
# them (the config-declared entry-point globs, plus the roots plugins publish: {PluginRoots}, #349).
|
|
245
245
|
# @param foreign — predicate answering "is this FQN owned by something outside the project?" —
|
|
246
246
|
# a reopened gem or stdlib class must never be a candidate (WD6). Defaults to "nothing is foreign".
|
|
247
247
|
# @param dynamic_uses — sites where a constant is reached by name at runtime.
|
|
@@ -281,8 +281,7 @@ module Rigor
|
|
|
281
281
|
# production for the same reason an unreached one is not dead (#1732).
|
|
282
282
|
live_namespaces = namespace_only(test_only, production)
|
|
283
283
|
test_only -= live_namespaces
|
|
284
|
-
# The data-file demotion applies to BOTH buckets it can speak to
|
|
285
|
-
# contract says and what the implementation had narrowed (#370). See {#tainted}.
|
|
284
|
+
# The data-file demotion applies to BOTH buckets it can speak to (#370). See {#tainted}.
|
|
286
285
|
undecidable = tainted(unreached).merge(tainted(test_only))
|
|
287
286
|
undecidable = spread_undecidable(edges, undecidable, unreached | test_only,
|
|
288
287
|
through: namespaces | live_namespaces)
|
|
@@ -91,8 +91,8 @@ module Rigor
|
|
|
91
91
|
# and write the same ADR-60 record-and-validate slots they use under `rigor check`, instead of
|
|
92
92
|
# recomputing from scratch — a routes parse or a factory discovery is a validated cache read on
|
|
93
93
|
# every invocation after the first. Nil keeps the historical recompute-always behaviour.
|
|
94
|
-
# @return sorted and de-duplicated. Empty whenever the project
|
|
95
|
-
# plugin contributes anything, or anything at all goes wrong.
|
|
94
|
+
# @return a {Contribution}, roots and references sorted and de-duplicated. Empty whenever the project
|
|
95
|
+
# declares no plugins, no plugin contributes anything, or anything at all goes wrong.
|
|
96
96
|
def collect(configuration:, plugin_requirer: ->(name) { require name }, cache_store: nil)
|
|
97
97
|
return Contribution.empty if configuration.plugins.empty?
|
|
98
98
|
|
|
@@ -40,7 +40,7 @@ module Rigor
|
|
|
40
40
|
# ADR-102 WD4 — a site where a constant is reached by a mechanism the static reading cannot follow.
|
|
41
41
|
# `name` is the exact constant when the argument is a literal (`"Foo".constantize`), in which case this
|
|
42
42
|
# is as good as a reference. `prefix` is what a dynamic construction can reach, and `scope` says how
|
|
43
|
-
# far — the
|
|
43
|
+
# far — the kinds of weak evidence are not the same shape:
|
|
44
44
|
#
|
|
45
45
|
# - `:namespace` — `"Foo::#{k}".constantize` can construct ANY name under `Foo`, so it taints `Foo`
|
|
46
46
|
# and every declaration beneath it. This is the default and the original meaning of `prefix`.
|
|
@@ -237,7 +237,7 @@ module Rigor
|
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
# `Const = Class.new` / `Module.new` / `Data.define(...)` / `Struct.new(...)` declare a class under a
|
|
240
|
-
# constant, and `ScopeIndexer
|
|
240
|
+
# constant, and `ScopeIndexer::ClassDeclarations` already treats them as class declarations
|
|
241
241
|
# for cross-file resolution. The report must agree, or every such constant reads as an unreferenced
|
|
242
242
|
# value rather than a class.
|
|
243
243
|
META_NEW = { "Class" => :new, "Module" => :new, "Data" => :define, "Struct" => :new }.freeze
|
|
@@ -443,7 +443,8 @@ module Rigor
|
|
|
443
443
|
],
|
|
444
444
|
does_not_fire_when: [
|
|
445
445
|
"The `return` is inside a nested `def`, a lambda (`->` / `lambda`), or a `define_method` " \
|
|
446
|
-
"block within the ensure body
|
|
446
|
+
"block within the ensure body, or the block of `send` / `__send__` / `public_send` naming " \
|
|
447
|
+
"`define_method` by a literal — it exits that inner frame, not the one the `ensure` guards.",
|
|
447
448
|
"The `ensure` body contains no explicit `return` (implicit last-expression values in `ensure` " \
|
|
448
449
|
"are discarded harmlessly and do not swallow exceptions)."
|
|
449
450
|
],
|
|
@@ -134,14 +134,7 @@ module Rigor
|
|
|
134
134
|
)
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
-
#
|
|
138
|
-
# for a released gem. A checkout (a contributor's, or a `bundle add rigor, github:` clone) gets one
|
|
139
|
-
# extra slot carrying a digest of the engine's own source, so editing `lib/rigor/inference/*.rb` no
|
|
140
|
-
# longer replays the pre-edit diagnostics out of a warm cache. A released install adds NO entry, so
|
|
141
|
-
# its key — and its hit rate — are exactly what they were.
|
|
142
|
-
#
|
|
143
|
-
# {Cache::EngineSource::Unavailable} is left to propagate into `descriptor`'s rescue, which disables
|
|
144
|
-
# the cache for the run: an engine we cannot identify must not be keyed by its version alone.
|
|
137
|
+
# #392 — the `template-units` slot; a nil digest (no plugin claimed a template glob) adds none.
|
|
145
138
|
def template_unit_entries(digest)
|
|
146
139
|
digest.nil? ? [] : [config_entry("template-units", digest)]
|
|
147
140
|
end
|
|
@@ -155,6 +148,14 @@ module Rigor
|
|
|
155
148
|
identity.nil? ? [] : [config_entry("shadow-harness", identity)]
|
|
156
149
|
end
|
|
157
150
|
|
|
151
|
+
# Issue #285 — the `engine` slot above pins the engine by VERSION, which identifies the source only
|
|
152
|
+
# for a released gem. A checkout (a contributor's, or a `bundle add rigor, github:` clone) gets one
|
|
153
|
+
# extra slot carrying a digest of the engine's own source, so editing `lib/rigor/inference/*.rb` no
|
|
154
|
+
# longer replays the pre-edit diagnostics out of a warm cache. A released install adds NO entry, so
|
|
155
|
+
# its key — and its hit rate — are exactly what they were.
|
|
156
|
+
#
|
|
157
|
+
# {Cache::EngineSource::Unavailable} is left to propagate into `descriptor`'s rescue, which disables
|
|
158
|
+
# the cache for the run: an engine we cannot identify must not be keyed by its version alone.
|
|
158
159
|
def engine_source_entries
|
|
159
160
|
Cache::EngineSource.key_config_entries
|
|
160
161
|
end
|
|
@@ -85,8 +85,8 @@ module Rigor
|
|
|
85
85
|
# @param workers — pool size. `#analyze` degrades to sequential in-process execution — one
|
|
86
86
|
# job at a time, no `fork` — when fewer than 2 bindings are submitted, fewer than `min_batch_size`
|
|
87
87
|
# bindings are submitted, `workers` is not positive, `fork` is unavailable on this platform, or
|
|
88
|
-
# `cache_store` is nil. The
|
|
89
|
-
# {DEFAULT_MIN_BATCH_SIZE}; the
|
|
88
|
+
# `cache_store` is nil. The first two are the fork-pool-is-not-worth-it-yet gate documented on
|
|
89
|
+
# {DEFAULT_MIN_BATCH_SIZE}; the rest mirror
|
|
90
90
|
# {PoolCoordinator#analyze_files_in_pool}'s own fork-pool preconditions.
|
|
91
91
|
# @param min_batch_size — see {DEFAULT_MIN_BATCH_SIZE}. Exposed as a constructor param
|
|
92
92
|
# (rather than read from the env internally) purely for spec control; production callers get the
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../cache/descriptor"
|
|
4
|
+
require_relative "../../cache/file_digest"
|
|
5
|
+
require_relative "../../cache/rbs_descriptor"
|
|
6
|
+
require_relative "../../environment/bundle_sig_discovery"
|
|
7
|
+
require_relative "../path_expansion"
|
|
8
|
+
|
|
9
|
+
module Rigor
|
|
10
|
+
module Analysis
|
|
11
|
+
class Runner
|
|
12
|
+
# The leaf rows of the run dependency descriptor and of the `--incremental` slot's rows: what a cached
|
|
13
|
+
# run answer depends on, as {Cache::Descriptor} file and glob entries. Each entry is a function of its
|
|
14
|
+
# arguments, with the {Runner}'s instance state passed in (a `Runner` ivar is a parameter of the same
|
|
15
|
+
# name), and returns rows; none writes anything. {Runner} keeps the assembly: which rows a run puts
|
|
16
|
+
# together (`build_run_dependency_descriptor`, `incremental_slot_rows`, `baseline_dependency_rows`)
|
|
17
|
+
# and the memo the descriptor is kept in.
|
|
18
|
+
#
|
|
19
|
+
# The run KEY is {RunCacheKey}'s; these rows are its validation half, re-digested on the next run by
|
|
20
|
+
# {Cache::Descriptor#fresh?}.
|
|
21
|
+
module DependencyRows
|
|
22
|
+
module_function
|
|
23
|
+
|
|
24
|
+
# #1962 / #1555 — a kind row per path the run's answer depends on the presence and kind of, not only its
|
|
25
|
+
# bytes. An analysis root: its path errors (`no such file or directory`, `not a Ruby file`) answer to whether
|
|
26
|
+
# it exists and whether it is a directory or a file, while what a directory root holds is the analysed-file
|
|
27
|
+
# set the key carries. A `pre_eval:` entry: `pre-eval.file-not-found` answers to whether it is a file (one
|
|
28
|
+
# that is has its `:stat` row from {#pre_eval_file_entries}). A project signature root, configured or the
|
|
29
|
+
# auto-detected `sig`: the loader reads a directory and a file differently, and #979's listing rows cover a
|
|
30
|
+
# file appearing under a root that existed, not the root appearing. A kind row rather than an existence row,
|
|
31
|
+
# because a directory replaced by a file of the same name leaves an existence row fresh. The `--incremental`
|
|
32
|
+
# slot records kind rows for the same paths ({Runner#incremental_slot_rows},
|
|
33
|
+
# {Runner#baseline_dependency_rows}, #1977).
|
|
34
|
+
def root_presence_entries(roots, pre_eval, signature_root_candidates)
|
|
35
|
+
(roots + pre_eval + signature_root_candidates)
|
|
36
|
+
.uniq.map { |path| Cache::Descriptor::FileEntry.kind(path: path) }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Every file a plugin read or probed through its `IoBoundary` (#577 / #613), and every directory it listed
|
|
40
|
+
# (#954), as the boundaries stand when asked.
|
|
41
|
+
def plugin_boundary_rows(plugins)
|
|
42
|
+
files = []
|
|
43
|
+
globs = []
|
|
44
|
+
plugins.each do |plugin|
|
|
45
|
+
# Read the boundary WITHOUT triggering its lazy `@io_boundary ||=` initializer: plugin instances
|
|
46
|
+
# are frozen after the run, and a plugin that never built a boundary read no files through it,
|
|
47
|
+
# so it contributes no dependencies.
|
|
48
|
+
boundary = plugin.instance_variable_get(:@io_boundary)
|
|
49
|
+
next unless boundary
|
|
50
|
+
|
|
51
|
+
# #629 — a boundary carries GlobEntry listing rows too (`IoBoundary#list_directory`), and they
|
|
52
|
+
# are the only edge back to a file the run decided was ABSENT from a directory it consulted.
|
|
53
|
+
boundary_descriptor = boundary.cache_descriptor
|
|
54
|
+
files.concat(boundary_descriptor.files)
|
|
55
|
+
globs.concat(boundary_descriptor.globs)
|
|
56
|
+
end
|
|
57
|
+
Cache::Descriptor.new(files: files, globs: globs)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# One glob row per producer `watch:` pattern (ADR-60 WD3), recomputed against the tree as it stands.
|
|
61
|
+
def producer_watch_glob_entries(plugins)
|
|
62
|
+
plugins.flat_map do |plugin|
|
|
63
|
+
plugin.class.producers.each_value.flat_map do |prod|
|
|
64
|
+
prod[:watch] ? plugin.send(:watch_glob_entries, prod[:watch]) : []
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Whether every boundary row that appeared or changed during the per-file loop is one some file's analysis
|
|
70
|
+
# was credited with. A row outside every file's attribution would ride this run's `run` rows only, and the
|
|
71
|
+
# next narrowed run — which does not repeat the read — would drop it.
|
|
72
|
+
def analysis_reads_attributed?(post, pre, analysis_reads)
|
|
73
|
+
credited = analysis_reads.each_value.flat_map(&:itself).to_set
|
|
74
|
+
(post.files - pre.files).all? { |row| credited.include?(row) } &&
|
|
75
|
+
(post.globs - pre.globs).all? { |row| credited.include?(row) }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# A loader's two readers {Cache::RbsDescriptor} takes signature roots from. `core_root` (issue #2517) is the
|
|
79
|
+
# selected core, which the slot key names by path only, so its files are `owned` rows like the project's own.
|
|
80
|
+
SignatureRoots = Struct.new(:signature_paths, :core_root)
|
|
81
|
+
private_constant :SignatureRoots
|
|
82
|
+
|
|
83
|
+
# The signature tree's rows, the project's own and the rest.
|
|
84
|
+
def signature_rows(signature_paths, core_root, signature_root_candidates)
|
|
85
|
+
roots = SignatureRoots.new(signature_paths, core_root)
|
|
86
|
+
own = (signature_root_candidates + [core_root].compact)
|
|
87
|
+
.map { |root| File.join(File.absolute_path(root.to_s), "") }
|
|
88
|
+
own_files, other_files = Cache::RbsDescriptor.file_entries(roots, comparator: :stat)
|
|
89
|
+
.partition { |row| within?(row.path, own) }
|
|
90
|
+
own_globs, other_globs = Cache::RbsDescriptor.glob_entries(roots).partition { |row| within?(row.root, own) }
|
|
91
|
+
[Cache::Descriptor.new(files: own_files, globs: own_globs.uniq),
|
|
92
|
+
Cache::Descriptor.new(files: other_files, globs: other_globs.uniq)]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def within?(path, roots)
|
|
96
|
+
directory = File.join(File.absolute_path(path.to_s), "")
|
|
97
|
+
roots.any? { |root| directory.start_with?(root) }
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# One names-mode listing row per directory the discovery widening globbed, so a file appearing there is seen
|
|
101
|
+
# as well as an edit to one that existed. Issue #1583 — keyed on the widening decision, not on what it
|
|
102
|
+
# added: a run over `lib/b.rb` alone in `lib` widens to nothing, and a `lib/a.rb` created afterwards must
|
|
103
|
+
# still move the answer of the run-result cache and the `--incremental` slot.
|
|
104
|
+
def discovery_glob_entries(discovery_widened, paths)
|
|
105
|
+
return [] unless discovery_widened
|
|
106
|
+
|
|
107
|
+
paths.select { |root| File.directory?(root) }.map do |root|
|
|
108
|
+
Cache::Descriptor::GlobEntry.compute(root: root, pattern: PathExpansion::RUBY_GLOB, mode: :names)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Issue #2987 — one names-mode listing row per bundle `sig/` layout ({Environment::BundleSigDiscovery.discover}'s
|
|
113
|
+
# two globs). The signature rows list only the directories the loader read, so a gem that GAINS a `sig/`
|
|
114
|
+
# (or loses it) while its version and lock entry stand still sits in none of them, and the run-result
|
|
115
|
+
# slot kept serving the environment built without (or with) it.
|
|
116
|
+
def bundle_sig_glob_entries(bundler_bundle_path, bundler_auto_detect)
|
|
117
|
+
root = Environment::BundleSigDiscovery.resolve_bundle_path(
|
|
118
|
+
bundle_path: bundler_bundle_path, project_root: Dir.pwd,
|
|
119
|
+
auto_detect: bundler_auto_detect
|
|
120
|
+
)
|
|
121
|
+
return [] if root.nil?
|
|
122
|
+
|
|
123
|
+
Environment::BundleSigDiscovery::SIG_GLOBS.map do |pattern|
|
|
124
|
+
Cache::Descriptor::GlobEntry.compute(root: root.to_s, pattern: pattern, mode: :names)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def unanalysed_pre_eval_entries(files, pre_eval, buffer)
|
|
129
|
+
analysed = files.to_set { |path| File.absolute_path(path) }
|
|
130
|
+
outside = pre_eval.reject { |path| analysed.include?(File.absolute_path(path)) }
|
|
131
|
+
outside.map do |path|
|
|
132
|
+
if File.file?(path)
|
|
133
|
+
Cache::Descriptor::FileEntry.stat(path: path, digest: Cache::FileDigest.hexdigest(path))
|
|
134
|
+
else
|
|
135
|
+
kind_entries([path], buffer).first
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# #1977 — one `:kind` row per path, the row {#root_presence_entries} records in the plain slot.
|
|
141
|
+
def kind_entries(paths, buffer)
|
|
142
|
+
paths.uniq.map do |path|
|
|
143
|
+
Cache::Descriptor::FileEntry.kind(path: buffer ? buffer.resolve(path) : path)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Issue #684 — the project files this run DISCOVERED but did not analyse. A widened run's diagnostics
|
|
148
|
+
# are a function of them (that is the entire point: the method whose absence would have been reported
|
|
149
|
+
# is defined in one of them), so the run-result cache must invalidate when one changes. Empty on every
|
|
150
|
+
# run whose discovery expansion is its analysis expansion, which is every whole-project run.
|
|
151
|
+
def discovery_file_entries(expansion, project_discovery_expansion, buffer)
|
|
152
|
+
return [] if project_discovery_expansion.nil?
|
|
153
|
+
|
|
154
|
+
analyzed = expansion.fetch(:files).to_set
|
|
155
|
+
analyzed_file_entries(
|
|
156
|
+
{ files: project_discovery_expansion.fetch(:files).reject { |path| analyzed.include?(path) } }, buffer
|
|
157
|
+
)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def analyzed_file_entries(expansion, buffer)
|
|
161
|
+
expansion.fetch(:files).map do |path|
|
|
162
|
+
physical = buffer ? buffer.resolve(path) : path
|
|
163
|
+
# ADR-87 WD1 — validation-only dependency descriptor, so the stat-then-digest `:stat` comparator
|
|
164
|
+
# applies (the env-cache KEY files stay `:digest`).
|
|
165
|
+
Cache::Descriptor::FileEntry.stat(path: physical, digest: Cache::FileDigest.hexdigest(physical))
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Every template the run READ, successes and failures alike: a `plugin_loader` row produced by a
|
|
170
|
+
# template that would not compile must not outlive the edit that fixes it, and a buffer-bound path is
|
|
171
|
+
# digested at the bytes the run actually read.
|
|
172
|
+
#
|
|
173
|
+
# #392 — the TEMPLATE files behind the run's units. The key slot carries the compiled Ruby's digest
|
|
174
|
+
# (`template_units_digest`), which is what decides whether a cached answer describes this source; these
|
|
175
|
+
# entries are the validation half, so a template edited between two runs re-globs and re-digests here
|
|
176
|
+
# exactly as an analysed `.rb` file does. Both are needed: a transform that compiles two different
|
|
177
|
+
# templates to the same Ruby must still not resurrect the wrong PATH in a diagnostic.
|
|
178
|
+
def template_unit_file_entries(template_units, buffer)
|
|
179
|
+
template_units.source_paths.filter_map do |path|
|
|
180
|
+
physical = template_units.physical_path(path, buffer)
|
|
181
|
+
next unless File.file?(physical)
|
|
182
|
+
|
|
183
|
+
Cache::Descriptor::FileEntry.stat(path: physical, digest: Cache::FileDigest.hexdigest(physical))
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Issue #352 — a `pre_eval:` file is a real input to the run's diagnostics: its `def`s populate the
|
|
188
|
+
# ADR-17 patched-method registry and (since #352) its constants populate the project seed. ADR-17 WD5
|
|
189
|
+
# permits listing a file under `pre_eval:` and NOT under `paths:`, and such a file never appears in the
|
|
190
|
+
# expansion — so without this entry, editing one would leave the run-result cache serving diagnostics
|
|
191
|
+
# computed against the previous version. The common case (a `lib/core_ext/` file that is also under
|
|
192
|
+
# `paths:`) contributes a duplicate entry, which the descriptor's per-path validation absorbs.
|
|
193
|
+
def pre_eval_file_entries(pre_eval, buffer)
|
|
194
|
+
pre_eval.filter_map do |path|
|
|
195
|
+
physical = buffer ? buffer.resolve(path) : path
|
|
196
|
+
next unless File.file?(physical)
|
|
197
|
+
|
|
198
|
+
Cache::Descriptor::FileEntry.stat(path: physical, digest: Cache::FileDigest.hexdigest(physical))
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
private_class_method :within?
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
@@ -20,9 +20,9 @@ module Rigor
|
|
|
20
20
|
#
|
|
21
21
|
# The collaborator holds the immutable per-run inputs (the configuration and the three mutable
|
|
22
22
|
# reporter accumulators, which are shared instances the dispatcher records into). The per-run varying
|
|
23
|
-
# state produced by other passes (the plugin registry, the dependency-source index
|
|
24
|
-
#
|
|
25
|
-
#
|
|
23
|
+
# state produced by other passes (the plugin registry, the dependency-source index) is read through
|
|
24
|
+
# injected reader procs so this collaborator never calls back into the {Runner} and the read happens at
|
|
25
|
+
# the exact point in the run the original inline read did.
|
|
26
26
|
class DiagnosticAggregator # rubocop:disable Metrics/ClassLength
|
|
27
27
|
# @param plugin_registry — reader returning the current {Plugin::Registry} (varies per run).
|
|
28
28
|
# @param dependency_source_index — reader returning the current
|
|
@@ -206,12 +206,7 @@ module Rigor
|
|
|
206
206
|
end
|
|
207
207
|
end
|
|
208
208
|
|
|
209
|
-
# ADR-10 § "
|
|
210
|
-
# `dependencies.budget_per_gem` cap. The cap is a Walker- side guard rail (slice 4 picks the (α)
|
|
211
|
-
# semantics from ADR-10 WD4: harvesting stops, the dispatcher behaves exactly as before for
|
|
212
|
-
# unrecorded methods). The diagnostic names the gem and points the user at the three remediations:
|
|
213
|
-
# ship RBS, reduce `mode:` from `full` to `when_missing`, or de-list the gem.
|
|
214
|
-
# ADR-10 § "config-conflict diagnostic" / 5d — surfaces `Configuration::Dependencies` warnings
|
|
209
|
+
# ADR-10 § "Public-API drift surface" — surfaces `Configuration::Dependencies` warnings
|
|
215
210
|
# accumulated during `from_h` deduplication of the `includes:`-chain source_inference array. Each
|
|
216
211
|
# warning describes a per-gem mode conflict that the merge resolved right-wins; the user sees one
|
|
217
212
|
# diagnostic per conflict. `:warning` matches the user's "warn but don't block" preference per the
|
|
@@ -230,6 +225,11 @@ module Rigor
|
|
|
230
225
|
end
|
|
231
226
|
end
|
|
232
227
|
|
|
228
|
+
# ADR-10 § "Budget interaction" / slice 4 — emits one `:warning` per gem whose Walker run hit the
|
|
229
|
+
# `dependencies.budget_per_gem` cap. The cap is a Walker-side guard rail (slice 4 picks the (α)
|
|
230
|
+
# semantics from ADR-10 WD4: harvesting stops, the dispatcher behaves exactly as before for
|
|
231
|
+
# unrecorded methods). The diagnostic names the gem and points the user at the three remediations:
|
|
232
|
+
# ship RBS, reduce `mode:` from `full` to `when_missing`, or de-list the gem.
|
|
233
233
|
def dependency_source_budget_diagnostics
|
|
234
234
|
budget = @configuration.dependencies.budget_per_gem
|
|
235
235
|
dependency_source_index.budget_exceeded.map do |gem_name|
|
|
@@ -413,12 +413,6 @@ module Rigor
|
|
|
413
413
|
)
|
|
414
414
|
end
|
|
415
415
|
|
|
416
|
-
# Robustness uplift companion (ADR-5) — when the project's `signature_paths:` RBS declared
|
|
417
|
-
# qualified names without their enclosing namespace, `RbsLoader` synthesizes the missing `module`s
|
|
418
|
-
# so the otherwise-inert signatures resolve. Surface a single `:info` diagnostic naming them so the
|
|
419
|
-
# user knows their sig set is malformed (`rbs validate` rejects it) and can fix it at the source.
|
|
420
|
-
# Authored `:info`: the analysis already succeeded; this is advisory, never a gate. Empty for a
|
|
421
|
-
# well-formed sig set.
|
|
422
416
|
# An unparseable or declaration-colliding `.rbs` under `signature_paths:` is QUARANTINED so the
|
|
423
417
|
# rest of the env survives (PR #50; issue #777 extends this to class-vs-module / constant
|
|
424
418
|
# collisions against bundled RBS), which means the types it declares are silently absent — calls
|
|
@@ -498,7 +492,7 @@ module Rigor
|
|
|
498
492
|
# step further in and one step narrower — the plugin entries are dropped, the `.rbs` scan still
|
|
499
493
|
# runs. Either way everything else this run reports is unaffected: no class loses its method
|
|
500
494
|
# surface, no signature file is skipped, the environment builds. That is why this sits LAST on the
|
|
501
|
-
# ladder, after its
|
|
495
|
+
# ladder, after its three `rbs.coverage.*` siblings above.
|
|
502
496
|
def rbs_hkt_scan_failed_diagnostics
|
|
503
497
|
failure = @snapshots[:hkt_scan_failure]
|
|
504
498
|
return [] if failure.nil?
|
|
@@ -506,6 +500,12 @@ module Rigor
|
|
|
506
500
|
[build_rbs_hkt_scan_failed_diagnostic(failure)]
|
|
507
501
|
end
|
|
508
502
|
|
|
503
|
+
# Robustness uplift companion (ADR-5) — when the project's `signature_paths:` RBS declared
|
|
504
|
+
# qualified names without their enclosing namespace, `RbsLoader` synthesizes the missing `module`s
|
|
505
|
+
# so the otherwise-inert signatures resolve. Surface a single `:info` diagnostic naming them so the
|
|
506
|
+
# user knows their sig set is malformed (`rbs validate` rejects it) and can fix it at the source.
|
|
507
|
+
# Authored `:info`: the analysis already succeeded; this is advisory, never a gate. Empty for a
|
|
508
|
+
# well-formed sig set.
|
|
509
509
|
def rbs_synthesized_namespace_diagnostics
|
|
510
510
|
synthesized = @snapshots[:synthesized_namespaces]
|
|
511
511
|
return [] if synthesized.nil? || synthesized.empty?
|
|
@@ -861,8 +861,8 @@ module Rigor
|
|
|
861
861
|
"#{sample.join(', ')}#{suffix}"
|
|
862
862
|
end
|
|
863
863
|
|
|
864
|
-
# Issue #784 — one `:error` row per run, unlike its
|
|
865
|
-
# Those
|
|
864
|
+
# Issue #784 — one `:error` row per run, unlike its three `:warning` `rbs.coverage.*` siblings above.
|
|
865
|
+
# Those three are typically a collision between the user's OWN `sig/` and Rigor's bundled RBS, so an
|
|
866
866
|
# `:error` default would let a Rigor release turn a green project red with zero user change (ADR-5
|
|
867
867
|
# / AGENTS.md § FP discipline) — the reason both stay `:warning` by default. This row has no such
|
|
868
868
|
# neighbour: post-#783 the scan itself raising is an ANALYZER defect, never something a user's
|
|
@@ -1111,10 +1111,12 @@ module Rigor
|
|
|
1111
1111
|
# to a carrier that loses precision (anything other than `HashShape` / `Tuple`).
|
|
1112
1112
|
# - `dynamic.rbs-extended.hkt-directive-invalid` for every malformed ADR-20 `rigor:v1:hkt_register` /
|
|
1113
1113
|
# `rigor:v1:hkt_define` the directive parser declined (issue #785).
|
|
1114
|
+
# - `dynamic.rbs-extended.deprecated-form` for every annotation still written in a deprecated spelling
|
|
1115
|
+
# (ADR-109 WD3).
|
|
1114
1116
|
#
|
|
1115
|
-
# All
|
|
1117
|
+
# All four are authored `:info`; the severity profile re-stamps them per project taste. Every stream
|
|
1116
1118
|
# carries its `(path, line, column)` already flattened off the annotation's `RBS::Location`, because
|
|
1117
|
-
# all
|
|
1119
|
+
# all four cross the pool drain channel (see {RbsExtended::Reporter}); an entry with no position
|
|
1118
1120
|
# falls back to `.rigor.yml`-style file-level attribution.
|
|
1119
1121
|
def rbs_extended_reporter_diagnostics
|
|
1120
1122
|
unresolved_payload_diagnostics + lossy_projection_diagnostics + hkt_directive_diagnostics +
|
|
@@ -1311,7 +1313,7 @@ module Rigor
|
|
|
1311
1313
|
# - `served_run_disclosures` (#2020), the rows an incremental recheck replays for the files it served
|
|
1312
1314
|
# from cache, since their per-file hooks did not run.
|
|
1313
1315
|
#
|
|
1314
|
-
#
|
|
1316
|
+
# All are keyed `[plugin id, key]` and the first registration of a pair wins, so a run emits one
|
|
1315
1317
|
# row per pair no matter how many plugin instances (workers) reached it — the #1051 bug, where a
|
|
1316
1318
|
# per-instance `@emitted` flag produced one row per WORKER.
|
|
1317
1319
|
#
|
|
@@ -1445,7 +1447,7 @@ module Rigor
|
|
|
1445
1447
|
)
|
|
1446
1448
|
end
|
|
1447
1449
|
|
|
1448
|
-
# The {RbsExtended::Reporter} form of the builder above: its
|
|
1450
|
+
# The {RbsExtended::Reporter} form of the builder above: its four streams carry the position as
|
|
1449
1451
|
# `(path, line, column)` primitives rather than as the `RBS::Location` a conformance record holds,
|
|
1450
1452
|
# because they cross the pool drain channel (#785, #805). A missing component falls back exactly as
|
|
1451
1453
|
# {#location_fields} does for a missing location.
|