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
data/lib/rigor/configuration.rb
CHANGED
|
@@ -1,271 +1,36 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "yaml"
|
|
4
|
-
|
|
5
3
|
require_relative "bleeding_edge"
|
|
6
4
|
require_relative "ci_detector"
|
|
5
|
+
require_relative "configuration/coercion"
|
|
6
|
+
require_relative "configuration/defaults"
|
|
7
7
|
require_relative "configuration/dependencies"
|
|
8
|
+
require_relative "configuration/loader"
|
|
8
9
|
require_relative "configuration/severity_profile"
|
|
9
|
-
require_relative "config_path"
|
|
10
10
|
require_relative "configuration_error"
|
|
11
|
-
require_relative "rooted_glob"
|
|
12
|
-
require_relative "effects/entry_points"
|
|
13
|
-
require_relative "effects/label"
|
|
14
|
-
require_relative "effects/method_key"
|
|
15
11
|
|
|
16
12
|
module Rigor
|
|
17
13
|
class Configuration # rubocop:disable Metrics/ClassLength
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
# because the schema pins its own `default` against it.
|
|
33
|
-
DEFAULT_EFFECTS_SNAPSHOT_PATH = ".rigor-effects.yml"
|
|
14
|
+
# The constants that describe the keys live in {Defaults}; each is the same object here, so
|
|
15
|
+
# `Configuration::DEFAULTS` and the rest keep resolving for every reader.
|
|
16
|
+
DISCOVERY_ORDER = Defaults::DISCOVERY_ORDER
|
|
17
|
+
DEFAULT_PATH = Defaults::DEFAULT_PATH
|
|
18
|
+
DEFAULT_EFFECTS_SNAPSHOT_PATH = Defaults::DEFAULT_EFFECTS_SNAPSHOT_PATH
|
|
19
|
+
BUILTIN_EXCLUDES = Defaults::BUILTIN_EXCLUDES
|
|
20
|
+
CONVENTIONAL_TEST_PATHS = Defaults::CONVENTIONAL_TEST_PATHS
|
|
21
|
+
DEFAULTS = Defaults::DEFAULTS
|
|
22
|
+
CONFIGURABLE_PLUGIN_ISOLATIONS = Defaults::CONFIGURABLE_PLUGIN_ISOLATIONS
|
|
23
|
+
RESERVED_NAMESPACES = Defaults::RESERVED_NAMESPACES
|
|
24
|
+
KNOWN_KEYS = Defaults::KNOWN_KEYS
|
|
25
|
+
# The `rigor-rbs-inline` auto-wiring names belong to {Loader}, which reads them.
|
|
26
|
+
AUTOWIRED_RBS_INLINE_GEM = Loader::AUTOWIRED_RBS_INLINE_GEM
|
|
27
|
+
AUTOWIRED_RBS_INLINE_ID = Loader::AUTOWIRED_RBS_INLINE_ID
|
|
34
28
|
|
|
35
29
|
# ADR-103 WD15 — the {BleedingEdge::FEATURES} id that, when adopted, makes a loaded file with no
|
|
36
30
|
# `effects:` key behave as `effects: {}`. See {#coerce_effects}.
|
|
37
31
|
EFFECTS_ON_BY_DEFAULT_FEATURE_ID = "effects-on-by-default"
|
|
38
32
|
private_constant :EFFECTS_ON_BY_DEFAULT_FEATURE_ID
|
|
39
33
|
|
|
40
|
-
# Built-in exclusion patterns appended to `exclude:` so vendored dependencies, Bundler artefacts, and
|
|
41
|
-
# JavaScript node_modules are never analysed by accident when a directory glob expands. Users cannot
|
|
42
|
-
# disable these defaults; the trade-off is that analysing any of these paths is essentially never what
|
|
43
|
-
# the user wants (they're build outputs / external dependencies, not source).
|
|
44
|
-
#
|
|
45
|
-
# We deliberately keep this list narrow. `tmp/` and similar directories vary across project layouts
|
|
46
|
-
# (Rails has `tmp/`, libraries usually don't); user-supplied `exclude:` entries in `.rigor.yml` cover the
|
|
47
|
-
# project-specific cases.
|
|
48
|
-
BUILTIN_EXCLUDES = %w[
|
|
49
|
-
**/vendor/bundle/**
|
|
50
|
-
**/.bundle/**
|
|
51
|
-
**/node_modules/**
|
|
52
|
-
].freeze
|
|
53
|
-
|
|
54
|
-
# The conventional test roots `test_paths: nil` auto-detects, in this order.
|
|
55
|
-
CONVENTIONAL_TEST_PATHS = %w[spec test].freeze
|
|
56
|
-
|
|
57
|
-
DEFAULTS = {
|
|
58
|
-
"target_ruby" => "4.0",
|
|
59
|
-
"paths" => ["lib"],
|
|
60
|
-
"exclude" => [],
|
|
61
|
-
"plugins" => [],
|
|
62
|
-
"disable" => [],
|
|
63
|
-
"libraries" => [],
|
|
64
|
-
"signature_paths" => nil,
|
|
65
|
-
# Issue #2517 — a core signature directory loaded IN PLACE OF the `rbs` gem's `core/` (a provider such as
|
|
66
|
-
# rbs-shifter writes one for an older CRuby). `nil` (the default) loads the gem's core. Unlike
|
|
67
|
-
# `signature_paths:`, which only adds, this replaces: the default core is not loaded beside it.
|
|
68
|
-
"core_root" => nil,
|
|
69
|
-
# The project's test roots: the directories (or files) holding its tests. `nil` (the default) auto-detects
|
|
70
|
-
# whichever of `spec/` and `test/` exist, the same way `signature_paths: nil` auto-detects `sig/`; `[]`
|
|
71
|
-
# declares that the project has none. `rigor sig-gen --params=observed` harvests call-site observations
|
|
72
|
-
# from them when no `--observe=PATH` is given. See {#resolved_test_paths}.
|
|
73
|
-
"test_paths" => nil,
|
|
74
|
-
# ADR-112 WD4 — `rigor sig-gen` settings. `inline_declared:` decides what happens to a method the inline
|
|
75
|
-
# reader (`rigor-rbs-inline`) already declares from `# @rbs` / `#:`. `write` (the default) copies the
|
|
76
|
-
# inline declaration into `sig/`, so the generated signature is the complete contract a gem ships;
|
|
77
|
-
# `skip` leaves every member that reader declares out of `sig/`, for a project whose Steep reads the
|
|
78
|
-
# same annotations (`inline: true` beside `signature "sig"`), where the copy would be a second
|
|
79
|
-
# declaration of one method (`DuplicatedMethodDefinition`). See {#sig_gen_inline_declared}.
|
|
80
|
-
"sig_gen" => {
|
|
81
|
-
"inline_declared" => "write"
|
|
82
|
-
},
|
|
83
|
-
# ADR-17 — project-side monkey-patch pre-evaluation. Empty by default; users opt in by listing explicit
|
|
84
|
-
# files (or globs) that the analyzer walks before per-file inference so patched-method declarations are
|
|
85
|
-
# visible across the project (e.g. `lib/core_ext/string_extensions.rb`). A missing literal path surfaces
|
|
86
|
-
# as `pre-eval.file-not-found`.
|
|
87
|
-
"pre_eval" => [],
|
|
88
|
-
# ADR-22 — baseline file path. nil (default) means no baseline is loaded; the `false` literal is
|
|
89
|
-
# treated as the explicit-disable form for `.rigor.yml`-side override of an upstream `.rigor.dist.yml`
|
|
90
|
-
# `baseline:` declaration. The presence of `.rigor-baseline.yml` on disk alone does NOT activate
|
|
91
|
-
# filtering — the path must be named here (WD2 (b) of ADR-22).
|
|
92
|
-
"baseline" => nil,
|
|
93
|
-
"fold_platform_specific_paths" => false,
|
|
94
|
-
# ADR-67 WD6a — opt-in call-site parameter type inference on the `check` walk. When `true`, `rigor
|
|
95
|
-
# check` runs the {Inference::ParameterInferenceCollector} as a one-round pre-pass into the discovery
|
|
96
|
-
# seed, so an undeclared `def` / `initialize` / setter parameter is typed to the union of its resolved
|
|
97
|
-
# call-site argument types (precision-additive only — the in-body negative rules decline on the inferred
|
|
98
|
-
# lower bound, WD6b). `false` (the default, resolved off by every severity profile) keeps the table empty
|
|
99
|
-
# and the run byte-identical to today. Composes with `--incremental` (the WD6c mutual exclusion is
|
|
100
|
-
# lifted): the incremental session recomputes the table each run and diffs it against its snapshot,
|
|
101
|
-
# re-checking any callee whose seeds moved.
|
|
102
|
-
"parameter_inference" => false,
|
|
103
|
-
# ADR-103 WD13 — the effect-labels opt-in, and the ONLY thing that turns effect collection on
|
|
104
|
-
# besides running `rigor effects`. **Presence is the switch**: `effects: {}` — or the bare key, which
|
|
105
|
-
# YAML parses as nil — enables collection with every sub-key at its default, because an annotation in
|
|
106
|
-
# a project's RBS must never create a project-wide cost cliff (that case earns a `:info` residual
|
|
107
|
-
# instead, #384).
|
|
108
|
-
#
|
|
109
|
-
# The default is `false` rather than `nil` precisely because presence is the switch and
|
|
110
|
-
# `Configuration.load` merges these DEFAULTS UNDER the loaded file: a `nil` default would be
|
|
111
|
-
# indistinguishable from a user's bare `effects:` key and would turn collection on for every project
|
|
112
|
-
# in existence. `false` is also the explicit-disable form a `.rigor.yml` uses to override an upstream
|
|
113
|
-
# `.rigor.dist.yml`'s `effects:` block — the same shape `baseline:` uses.
|
|
114
|
-
#
|
|
115
|
-
# The sub-keys are declared in `schemas/rigor-config.schema.json`. `check` (#383,
|
|
116
|
-
# {#effects_check?}), `snapshot.{path,reach,gate}`, `tolerated` (#381) and the policy trio
|
|
117
|
-
# `labels` / `attribution` / `envelopes` (#385, {#coerce_effects_policy}) are read; `views` lands
|
|
118
|
-
# with the slice that implements it (#390). Reserving a sub-key's shape before a reader exists is
|
|
119
|
-
# the same discipline the schema applies to a sibling implementation's namespace (ADR-99).
|
|
120
|
-
"effects" => false,
|
|
121
|
-
"cache" => {
|
|
122
|
-
"path" => ".rigor/cache",
|
|
123
|
-
# LRU eviction cap in bytes (ADR-54 WD3). The least-recently-used entries are removed at the end of a
|
|
124
|
-
# run when the total exceeds this limit. The 256 MB default exists to reap orphans — entries whose
|
|
125
|
-
# content key nothing references any more (an rbs gem bump, a signature change) and that no run
|
|
126
|
-
# would otherwise ever delete; a full active per-project set is ~2 MB, so the cap never touches live
|
|
127
|
-
# entries. Set explicitly to `null` to disable eviction (pre-WD3 behaviour: the cache grows until
|
|
128
|
-
# `--clear-cache`).
|
|
129
|
-
"max_bytes" => 268_435_456,
|
|
130
|
-
# ADR-87 WD1 — file-freshness validation strategy. `"stat"` validates a recorded file
|
|
131
|
-
# dependency by stat-ing it first and re-hashing only when the `(size, mtime_ns, ctime_ns, inode)`
|
|
132
|
-
# tuple moved (or the racy window fires), so an unchanged monorepo hashes ~0 bytes on a warm run.
|
|
133
|
-
# `"digest"` restores the pre-ADR-87 behaviour of SHA-256'ing every recorded file on every run — the
|
|
134
|
-
# per-run escape hatch is the `RIGOR_STRICT_VALIDATION=1` env var, which wins over this setting.
|
|
135
|
-
# `"auto"` (default, #190) resolves per environment: `"digest"` when {CiDetector} recognises a CI
|
|
136
|
-
# provider — a fresh checkout regenerates every stat tuple, so the stat tier can never short-circuit
|
|
137
|
-
# there and stat-signature glob slots would recompute on every run — and `"stat"` everywhere else.
|
|
138
|
-
# A self-hosted runner with a persistent workspace opts back into the stat floor with an explicit
|
|
139
|
-
# `"stat"` (or `RIGOR_CI_DETECT=0`).
|
|
140
|
-
"validation" => "auto"
|
|
141
|
-
},
|
|
142
|
-
# ADR-39 slice 5 / #911 — the plugin-isolation strategy for target-library invocation. `nil` (the
|
|
143
|
-
# default) names nothing, leaving the choice to `RIGOR_PLUGIN_ISOLATION` and then to
|
|
144
|
-
# `Plugin::Isolation::DEFAULT`. The environment variable WINS over this key: it is the
|
|
145
|
-
# one-invocation operator override (`RIGOR_PLUGIN_ISOLATION=none rigor check` on a platform where
|
|
146
|
-
# the fork worker misbehaves), and an override a committed file can veto is not an override.
|
|
147
|
-
# Only `none` and `process` are selectable here — `ruby_box` needs `RUBY_BOX=1` set before Ruby
|
|
148
|
-
# boots, which is what `exe/rigor` re-execs for, and the launcher deliberately does not parse YAML
|
|
149
|
-
# before that re-exec (ADR-87 / ADR-104 boot-slim), so naming it here raises instead of silently
|
|
150
|
-
# resolving to a different strategy.
|
|
151
|
-
"plugins_isolation" => nil,
|
|
152
|
-
"plugins_io" => {
|
|
153
|
-
"network" => "disabled",
|
|
154
|
-
"allowed_paths" => [],
|
|
155
|
-
"allowed_url_hosts" => []
|
|
156
|
-
},
|
|
157
|
-
"severity_profile" => "balanced",
|
|
158
|
-
"severity_overrides" => {},
|
|
159
|
-
# ADR-50 § WD2 — bleeding-edge overlay opt-in. Selects which of the *next major's* queued changes
|
|
160
|
-
# ({Rigor::BleedingEdge}) this project adopts early. Orthogonal to `severity_profile:`. Accepts `false`
|
|
161
|
-
# (default — adopt none), `true` (adopt the whole overlay), a list of feature ids (adopt only those),
|
|
162
|
-
# or `{ all: true, except: [ids] }` (adopt all but the named). A queued change is either a severity
|
|
163
|
-
# promotion (composed by {SeverityProfile.resolve}) or a behaviour switch (read at its call site
|
|
164
|
-
# through {#bleeding_edge_active?}); `bleeding_edge:` selects both kinds the same way.
|
|
165
|
-
"bleeding_edge" => false,
|
|
166
|
-
"dependencies" => {
|
|
167
|
-
"source_inference" => [],
|
|
168
|
-
"budget_per_gem" => Configuration::Dependencies::DEFAULT_BUDGET_PER_GEM
|
|
169
|
-
},
|
|
170
|
-
"parallel" => {
|
|
171
|
-
# ADR-15 Phase 4c — when greater than zero, `rigor check` dispatches per-file analysis across N
|
|
172
|
-
# Ractor workers built around {Rigor::Analysis::WorkerSession}. `0` (default) keeps the sequential
|
|
173
|
-
# coordinator path bit-for-bit unchanged. The CLI's `--workers=N` flag and the `RIGOR_RACTOR_WORKERS`
|
|
174
|
-
# env var both override this setting; precedence is CLI > env > config > 0.
|
|
175
|
-
"workers" => 0
|
|
176
|
-
},
|
|
177
|
-
"bundler" => {
|
|
178
|
-
# Open item O4 — target-project Bundler awareness. When `bundle_path:` is set (or auto-detected),
|
|
179
|
-
# Rigor walks `<bundle_path>/ruby/*/gems/*/sig/` (RubyGems-sourced gems) and
|
|
180
|
-
# `<bundle_path>/ruby/*/bundler/gems/*/sig/` (`git:`-sourced gems) and adds each gem-shipped sig
|
|
181
|
-
# directory to `signature_paths:`. A `path:`-sourced gem is not under either — Bundler uses the
|
|
182
|
-
# `path:` directory in place rather than copying it into the bundle root — so add its `sig/` directly
|
|
183
|
-
# via `signature_paths:` instead. With O7's failure-memo in place, conflicts (a vendored sig already
|
|
184
|
-
# declares the same constant) degrade gracefully to "no RBS env" with a single-line warning naming
|
|
185
|
-
# the offending file, rather than hanging.
|
|
186
|
-
#
|
|
187
|
-
# `bundle_path:` (String, optional): explicit path to the bundler install root (e.g.,
|
|
188
|
-
# "vendor/bundle" or an absolute path). Resolved relative to the project root (`paths:`'s base) when
|
|
189
|
-
# relative.
|
|
190
|
-
#
|
|
191
|
-
# `auto_detect:` (Boolean, default true): when no explicit `bundle_path:` is set, try
|
|
192
|
-
# `.bundle/config`'s `BUNDLE_PATH:` first; fall back to `vendor/bundle/` under the project root if it
|
|
193
|
-
# exists. When neither is found, no extra sigs are added — the analyzer sees only rigor's vendored
|
|
194
|
-
# RBS and the user's `signature_paths:`.
|
|
195
|
-
#
|
|
196
|
-
# O4 Layer 3 keys:
|
|
197
|
-
#
|
|
198
|
-
# `lockfile:` (String, optional): explicit path to a `Gemfile.lock`. Resolved relative to the
|
|
199
|
-
# project root when relative. When set (or auto-detected via the `auto_detect:` flag below) Rigor
|
|
200
|
-
# parses the lockfile and uses it to FILTER the bundle-discovered `sig/` directories: only gems whose
|
|
201
|
-
# `(name, version, platform)` matches a lockfile entry are admitted to `signature_paths:`. Stale or
|
|
202
|
-
# out-of-band gems sitting in the bundle install tree are silently dropped.
|
|
203
|
-
#
|
|
204
|
-
# `auto_detect:` (Boolean, also gates the lockfile search): when true and `lockfile:` is nil, look
|
|
205
|
-
# for `<project_root>/Gemfile.lock`.
|
|
206
|
-
"bundle_path" => nil,
|
|
207
|
-
"auto_detect" => true,
|
|
208
|
-
"lockfile" => nil
|
|
209
|
-
},
|
|
210
|
-
"rbs_collection" => {
|
|
211
|
-
# Open item O4 Layer 3 slice 2 — `rbs collection install` awareness. When the target project has been
|
|
212
|
-
# set up with `rbs collection install`, the resulting `rbs_collection.lock.yaml` carries the resolved
|
|
213
|
-
# (gem, version, source) triples and `.gem_rbs_collection/` holds the downloaded `.rbs` files. Rigor
|
|
214
|
-
# parses the lockfile and auto-feeds each gem's `<collection_root>/<name>/<version>/` directory into
|
|
215
|
-
# `RbsLoader`'s `signature_paths:`. Sources of type `stdlib` install no directory; issue #2946 — they
|
|
216
|
-
# load as RBS libraries, appended to `DEFAULT_LIBRARIES + libraries:`, as the `rbs` CLI loads them.
|
|
217
|
-
#
|
|
218
|
-
# `lockfile:` (String, optional): explicit path to `rbs_collection.lock.yaml`. Resolved relative to
|
|
219
|
-
# the project root when relative.
|
|
220
|
-
#
|
|
221
|
-
# `auto_detect:` (Boolean, default true): when no explicit `lockfile:` is set, look for
|
|
222
|
-
# `<project_root>/rbs_collection.lock.yaml`.
|
|
223
|
-
"lockfile" => nil,
|
|
224
|
-
"auto_detect" => true
|
|
225
|
-
}
|
|
226
|
-
}.freeze
|
|
227
|
-
Ractor.make_shareable(DEFAULTS)
|
|
228
|
-
|
|
229
|
-
# Top-level keys whose values are file/directory paths that MUST be resolved relative to the config
|
|
230
|
-
# file's directory. `exclude:` is intentionally NOT in this list — its entries are glob patterns
|
|
231
|
-
# (`**/vendor/**`), not paths.
|
|
232
|
-
PATH_KEYS = %w[paths signature_paths test_paths pre_eval].freeze
|
|
233
|
-
private_constant :PATH_KEYS
|
|
234
|
-
|
|
235
|
-
# The single-path sibling of {PATH_KEYS}: resolved the same way, but kept a String rather than wrapped in an
|
|
236
|
-
# Array.
|
|
237
|
-
SCALAR_PATH_KEYS = %w[core_root].freeze
|
|
238
|
-
private_constant :SCALAR_PATH_KEYS
|
|
239
|
-
|
|
240
|
-
# Top-level keys this implementation DECLARES but never reads — see `docs/internal-spec/config.md`
|
|
241
|
-
# § "Reserved namespaces" and ADR-99.
|
|
242
|
-
#
|
|
243
|
-
# A sibling implementation (`rigor-rs`, which vendors our schema rather than keeping its own)
|
|
244
|
-
# groups keys for concepts we do not have under its own namespace, so one `.rigor.yml` feeds both.
|
|
245
|
-
# Such a key answers to the SCHEMA TIER ONLY: it is type-checked where it is written, and here it
|
|
246
|
-
# is never read, never validated, never coerced, and never an error however invalid its value.
|
|
247
|
-
#
|
|
248
|
-
# That is already the emergent behaviour — `#initialize` fetches each key it owns and never
|
|
249
|
-
# enumerates the rest — so this constant does not gate the runtime. It exists to make the
|
|
250
|
-
# reservation FINDABLE by the next person adding config validation (#166 is exactly that), and to
|
|
251
|
-
# give the schema-parity spec something to key on: a reserved namespace is by definition absent
|
|
252
|
-
# from DEFAULTS, so the DEFAULTS-driven schema gate can never see it.
|
|
253
|
-
# The isolation strategies a `.rigor.yml` may name (ADR-39 slice 5 / #911). `ruby_box` is
|
|
254
|
-
# deliberately absent: it is a boot-time decision the config file is read too late to make.
|
|
255
|
-
CONFIGURABLE_PLUGIN_ISOLATIONS = %w[none process].freeze
|
|
256
|
-
|
|
257
|
-
RESERVED_NAMESPACES = %w[rigor_rs].freeze
|
|
258
|
-
|
|
259
|
-
# Every top-level key a conforming `.rigor.yml` may carry: the keys this implementation owns, plus
|
|
260
|
-
# `includes:`, plus the namespaces reserved for another implementation. Anything else is recorded in
|
|
261
|
-
# {#unknown_keys} and warned about by {ConfigAudit}, and is also the did-you-mean dictionary for a
|
|
262
|
-
# near-miss.
|
|
263
|
-
#
|
|
264
|
-
# `includes:` is a load-time directive — {load_with_includes} `delete`s it while merging, so it never
|
|
265
|
-
# reaches `#initialize` and could not be seen as unknown regardless. It is listed because a user
|
|
266
|
-
# legitimately writes it, so a typo like `include:` must be able to suggest it.
|
|
267
|
-
KNOWN_KEYS = (DEFAULTS.keys + %w[includes] + RESERVED_NAMESPACES).freeze
|
|
268
|
-
|
|
269
34
|
# Top-level keys the loaded config carried that this implementation does not own — neither a
|
|
270
35
|
# {DEFAULTS} key, nor `includes:`, nor a reserved namespace. Recorded rather than acted on: an
|
|
271
36
|
# unknown key stays as inert at run time as it has always been, and {ConfigAudit} turns the record
|
|
@@ -348,39 +113,6 @@ module Rigor
|
|
|
348
113
|
[]
|
|
349
114
|
end
|
|
350
115
|
|
|
351
|
-
# Loads a configuration file.
|
|
352
|
-
#
|
|
353
|
-
# `path == nil` triggers auto-discovery against {DISCOVERY_ORDER}. The first present file in that list is
|
|
354
|
-
# loaded; if none exist the built-in {DEFAULTS} are used.
|
|
355
|
-
#
|
|
356
|
-
# When a path is supplied (whether by auto-discovery or by the caller) the YAML body is processed for
|
|
357
|
-
# `includes:` recursively, and every relative path inside path-bearing keys (`paths:`,
|
|
358
|
-
# `signature_paths:`, `plugins_io.allowed_paths:`, `includes:`) is resolved against THAT file's
|
|
359
|
-
# directory. The resolution is per-file: an included file's relative paths resolve against the included
|
|
360
|
-
# file's directory, not the top-level file. Path resolution mirrors
|
|
361
|
-
# [PHPStan](https://phpstan.org/config-reference#paths).
|
|
362
|
-
def self.load(path = nil)
|
|
363
|
-
resolved = path || discover
|
|
364
|
-
loaded = resolved && File.exist?(resolved) ? resolved : nil
|
|
365
|
-
if loaded.nil?
|
|
366
|
-
data = DEFAULTS
|
|
367
|
-
effects_key_present = false
|
|
368
|
-
target_ruby_key_present = false
|
|
369
|
-
else
|
|
370
|
-
# ADR-103 WD15 — captured from the RAW, pre-`DEFAULTS.merge` file (+ its `includes:` chain) because
|
|
371
|
-
# `DEFAULTS` itself carries an `"effects" => false` entry: once merged, "the file never wrote
|
|
372
|
-
# `effects:`" and "the file wrote `effects: false`" collapse to the same value and become
|
|
373
|
-
# indistinguishable to {#initialize}. This is the only place that distinction still exists.
|
|
374
|
-
raw = load_with_includes(loaded)
|
|
375
|
-
effects_key_present = raw.key?("effects")
|
|
376
|
-
target_ruby_key_present = raw.key?("target_ruby")
|
|
377
|
-
data = DEFAULTS.merge(raw)
|
|
378
|
-
end
|
|
379
|
-
new(autowire_default_plugins(data), effects_key_present, target_ruby_key_present || false)
|
|
380
|
-
.with_exclude_base(loaded && File.dirname(loaded))
|
|
381
|
-
.with_config_path(loaded)
|
|
382
|
-
end
|
|
383
|
-
|
|
384
116
|
# #1576 — the directory relative `exclude:` patterns are matched against: the directory of the config file in
|
|
385
117
|
# use (the base `paths:` resolve against), or the working directory when no config file is used.
|
|
386
118
|
def exclude_base
|
|
@@ -398,182 +130,32 @@ module Rigor
|
|
|
398
130
|
@config_path
|
|
399
131
|
end
|
|
400
132
|
|
|
401
|
-
#
|
|
402
|
-
#
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
133
|
+
# The loader is {Loader}. Each of these keeps its place on `Configuration`, where the CLI, the language server
|
|
134
|
+
# and the specs call it.
|
|
135
|
+
def self.load(path = nil)
|
|
136
|
+
Loader.load(path)
|
|
137
|
+
end
|
|
406
138
|
|
|
407
|
-
# ADR-93 WD2 — default-wire the bundled `rigor-rbs-inline` plugin, in WD1's annotation-gated,
|
|
408
|
-
# magic-comment-free mode, when the upstream `rbs-inline` library is resolvable and the user has not
|
|
409
|
-
# already listed the plugin. Runs from {load} only — the real-project route — never from a bare
|
|
410
|
-
# {Configuration.new}, so the suite's unit constructions do not auto-wire. The gate is presence-based
|
|
411
|
-
# (ADR-72's shape): an annotation-free project pays only a comment scan and contributes nothing, so
|
|
412
|
-
# wiring it on cannot regress the run. This partially reverses the ADR-27/ADR-31 auto-load deferral for
|
|
413
|
-
# this one bundled plugin (the executed code is already vendored, not arbitrary third-party plugin code).
|
|
414
|
-
# Opt out with a `plugins:` entry disabling it (`enabled: false`), or per-file `# rbs_inline: disabled`.
|
|
415
139
|
def self.autowire_default_plugins(data)
|
|
416
|
-
|
|
417
|
-
return data if entries.any? { |entry| rbs_inline_plugin_entry?(entry) }
|
|
418
|
-
return data unless rbs_inline_library_resolvable?
|
|
419
|
-
|
|
420
|
-
merged = data.dup
|
|
421
|
-
merged["plugins"] = entries + [{
|
|
422
|
-
"gem" => AUTOWIRED_RBS_INLINE_GEM,
|
|
423
|
-
"id" => AUTOWIRED_RBS_INLINE_ID,
|
|
424
|
-
"config" => { "require_magic_comment" => false }
|
|
425
|
-
}]
|
|
426
|
-
merged
|
|
140
|
+
Loader.autowire_default_plugins(data)
|
|
427
141
|
end
|
|
428
142
|
|
|
429
|
-
# True when a `plugins:` entry (String or Hash, string- or symbol-keyed) already references the
|
|
430
|
-
# `rigor-rbs-inline` plugin by gem name or by manifest id. Single-homed here so the CLI's
|
|
431
|
-
# `--treat-all-as-inline-rbs` injection and the WD2 auto-wire gate agree on what "already listed" means.
|
|
432
143
|
def self.rbs_inline_plugin_entry?(entry)
|
|
433
|
-
|
|
434
|
-
when String
|
|
435
|
-
entry == AUTOWIRED_RBS_INLINE_GEM
|
|
436
|
-
when Hash
|
|
437
|
-
string_keyed = entry.to_h { |k, v| [k.to_s, v] }
|
|
438
|
-
string_keyed["gem"] == AUTOWIRED_RBS_INLINE_GEM || string_keyed["id"] == AUTOWIRED_RBS_INLINE_ID
|
|
439
|
-
else
|
|
440
|
-
false
|
|
441
|
-
end
|
|
144
|
+
Loader.rbs_inline_plugin_entry?(entry)
|
|
442
145
|
end
|
|
443
146
|
|
|
444
|
-
# A probe with no load side effect: it does not `require` the library, only asks whether RubyGems can
|
|
445
|
-
# resolve the name. `Gem::Specification.find_by_name` raises `Gem::MissingSpecError` (a `Gem::LoadError`)
|
|
446
|
-
# when the gem is absent — the standalone `gem install rigortype` case, WD3's residual. ADR-90's
|
|
447
|
-
# project-bundle fallback resolves the same name at the plugin's own `require` time.
|
|
448
147
|
def self.rbs_inline_library_resolvable?
|
|
449
|
-
|
|
450
|
-
true
|
|
451
|
-
rescue Gem::LoadError
|
|
452
|
-
false
|
|
148
|
+
Loader.rbs_inline_library_resolvable?
|
|
453
149
|
end
|
|
454
150
|
|
|
455
|
-
# Returns the path to the config file Rigor would load under auto-discovery, or `nil` when neither
|
|
456
|
-
# candidate exists. Public so the CLI / spec drift checks can introspect the resolved file.
|
|
457
151
|
def self.discover
|
|
458
|
-
|
|
152
|
+
Loader.discover
|
|
459
153
|
end
|
|
460
154
|
|
|
461
|
-
# Reads `path` (which MUST exist) plus every file listed in its `includes:` chain, merging them under the
|
|
462
|
-
# order: included files first (in declaration order), then the current file's own keys override.
|
|
463
|
-
# Relative paths inside each file are resolved against that file's directory. Public so the CLI can run
|
|
464
|
-
# the include-aware load before applying `--treat-all-as-inline-rbs`'s plugin injection (see
|
|
465
|
-
# {CLI::CheckCommand#load_check_configuration}).
|
|
466
155
|
def self.load_with_includes(path, visited: Set.new)
|
|
467
|
-
|
|
468
|
-
raise ConfigurationError, "circular include: #{absolute}" if visited.include?(absolute)
|
|
469
|
-
|
|
470
|
-
raw = read_yaml(absolute)
|
|
471
|
-
raise ConfigurationError, "config file must be a YAML mapping: #{absolute}" unless raw.is_a?(Hash)
|
|
472
|
-
|
|
473
|
-
base_dir = File.dirname(absolute)
|
|
474
|
-
includes = Array(raw.delete("includes") || [])
|
|
475
|
-
data = resolve_paths_in(raw, base_dir)
|
|
476
|
-
next_visited = visited + [absolute]
|
|
477
|
-
merge_includes(data, includes, base_dir, next_visited)
|
|
478
|
-
end
|
|
479
|
-
|
|
480
|
-
# #433's sibling: a typo in the file the user is about to be told to fix is a configuration mistake
|
|
481
|
-
# like any other, and escaped as a `Psych::SyntaxError` backtrace naming a file inside Ruby's stdlib.
|
|
482
|
-
# Psych's own `#message` embeds the path in a parenthesised prefix that reads badly after `rigor: `,
|
|
483
|
-
# so the position is re-rendered in the `path:line:column` form the rest of Rigor's output uses.
|
|
484
|
-
def self.read_yaml(absolute)
|
|
485
|
-
YAML.safe_load_file(absolute, aliases: false) || {}
|
|
486
|
-
rescue Psych::SyntaxError => e
|
|
487
|
-
detail = [e.problem, e.context].compact.join(" ")
|
|
488
|
-
raise ConfigurationError, "#{absolute}:#{e.line}:#{e.column}: not valid YAML: #{detail}"
|
|
156
|
+
Loader.load_with_includes(path, visited: visited)
|
|
489
157
|
end
|
|
490
158
|
|
|
491
|
-
def self.merge_includes(data, includes, base_dir, visited)
|
|
492
|
-
return data if includes.empty?
|
|
493
|
-
|
|
494
|
-
accumulated = {}
|
|
495
|
-
includes.each do |inc|
|
|
496
|
-
inc_path = ConfigPath.absolute(inc.to_s, base_dir)
|
|
497
|
-
unless File.exist?(inc_path)
|
|
498
|
-
raise ConfigurationError, "include not found: #{inc.inspect} (referenced from #{base_dir})"
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
accumulated = deep_merge(accumulated, load_with_includes(inc_path, visited: visited))
|
|
502
|
-
end
|
|
503
|
-
deep_merge(accumulated, data)
|
|
504
|
-
end
|
|
505
|
-
|
|
506
|
-
# Per-file path resolution. Each path-bearing key listed in {PATH_KEYS} plus the nested
|
|
507
|
-
# `plugins_io.allowed_paths:` entries get their relative paths expanded against the config file's
|
|
508
|
-
# directory. `cache.path:` is intentionally left as-is so end-user messages (e.g. `--cache-stats` output)
|
|
509
|
-
# keep the project-relative form the user wrote.
|
|
510
|
-
def self.resolve_paths_in(data, base_dir)
|
|
511
|
-
return data unless data.is_a?(Hash)
|
|
512
|
-
|
|
513
|
-
out = data.dup
|
|
514
|
-
PATH_KEYS.each { |key| resolve_path_key!(out, key, base_dir) }
|
|
515
|
-
SCALAR_PATH_KEYS.each { |key| resolve_scalar_path_key!(out, key, base_dir) }
|
|
516
|
-
resolve_plugins_io_paths!(out, base_dir)
|
|
517
|
-
out
|
|
518
|
-
end
|
|
519
|
-
|
|
520
|
-
def self.resolve_path_key!(out, key, base_dir)
|
|
521
|
-
return unless out.key?(key) && !out[key].nil?
|
|
522
|
-
|
|
523
|
-
out[key] = Array(out[key]).map { |p| ConfigPath.absolute(p.to_s, base_dir) }
|
|
524
|
-
end
|
|
525
|
-
|
|
526
|
-
def self.resolve_scalar_path_key!(out, key, base_dir)
|
|
527
|
-
return unless out.key?(key) && out[key].is_a?(String)
|
|
528
|
-
|
|
529
|
-
out[key] = ConfigPath.absolute(out[key], base_dir)
|
|
530
|
-
end
|
|
531
|
-
|
|
532
|
-
def self.resolve_plugins_io_paths!(out, base_dir)
|
|
533
|
-
plugins_io = out["plugins_io"]
|
|
534
|
-
return unless plugins_io.is_a?(Hash) && plugins_io["allowed_paths"]
|
|
535
|
-
|
|
536
|
-
duped = plugins_io.dup
|
|
537
|
-
duped["allowed_paths"] = Array(plugins_io["allowed_paths"]).map { |p| ConfigPath.absolute(p.to_s, base_dir) }
|
|
538
|
-
out["plugins_io"] = duped
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
def self.deep_merge(left, right)
|
|
542
|
-
return right unless left.is_a?(Hash) && right.is_a?(Hash)
|
|
543
|
-
|
|
544
|
-
merged = left.dup
|
|
545
|
-
right.each do |key, value|
|
|
546
|
-
merged[key] = merge_value(key, merged, value)
|
|
547
|
-
end
|
|
548
|
-
merged
|
|
549
|
-
end
|
|
550
|
-
|
|
551
|
-
# Most keys are right-wins (override) or recursively merged hashes. ADR-10 § "config-conflict
|
|
552
|
-
# diagnostic" carves out `dependencies.source_inference[]`: the per-gem merge across `includes:` chains
|
|
553
|
-
# needs union behaviour with mode-conflict detection. The Hash itself still merges deeply; only the
|
|
554
|
-
# inner array gets concatenated so {Dependencies.from_h} sees every contributor's entries and can dedupe
|
|
555
|
-
# them.
|
|
556
|
-
def self.merge_value(key, merged, value)
|
|
557
|
-
if key == "dependencies" && merged[key].is_a?(Hash) && value.is_a?(Hash)
|
|
558
|
-
merge_dependencies_hash(merged[key], value)
|
|
559
|
-
elsif merged.key?(key) && merged[key].is_a?(Hash) && value.is_a?(Hash)
|
|
560
|
-
deep_merge(merged[key], value)
|
|
561
|
-
else
|
|
562
|
-
value
|
|
563
|
-
end
|
|
564
|
-
end
|
|
565
|
-
|
|
566
|
-
def self.merge_dependencies_hash(left, right)
|
|
567
|
-
out = deep_merge(left, right)
|
|
568
|
-
left_si = Array(left["source_inference"])
|
|
569
|
-
right_si = Array(right["source_inference"])
|
|
570
|
-
both_empty = left_si.empty? && right_si.empty?
|
|
571
|
-
out["source_inference"] = left_si + right_si unless both_empty # rigor:disable flow.always-truthy-condition
|
|
572
|
-
out
|
|
573
|
-
end
|
|
574
|
-
private_class_method :merge_includes, :resolve_paths_in, :deep_merge,
|
|
575
|
-
:merge_value, :merge_dependencies_hash
|
|
576
|
-
|
|
577
159
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
578
160
|
#
|
|
579
161
|
# @param effects_key_present — ADR-103 WD15 — whether the file this `data` came from carried an
|
|
@@ -599,26 +181,26 @@ module Rigor
|
|
|
599
181
|
cache = DEFAULTS.fetch("cache").merge(data.fetch("cache", {}))
|
|
600
182
|
plugins_io = DEFAULTS.fetch("plugins_io").merge(data.fetch("plugins_io", {}))
|
|
601
183
|
|
|
602
|
-
@target_ruby = coerce_target_ruby(data.fetch("target_ruby", DEFAULTS.fetch("target_ruby")))
|
|
184
|
+
@target_ruby = Coercion.coerce_target_ruby(data.fetch("target_ruby", DEFAULTS.fetch("target_ruby")))
|
|
603
185
|
@target_ruby_explicit = target_ruby_key_present ? true : false
|
|
604
186
|
@paths = Array(data.fetch("paths", DEFAULTS.fetch("paths"))).map(&:to_s).freeze
|
|
605
187
|
user_excludes = Array(data.fetch("exclude", DEFAULTS.fetch("exclude"))).map(&:to_s)
|
|
606
188
|
@exclude_patterns = (BUILTIN_EXCLUDES + user_excludes).uniq.freeze
|
|
607
189
|
@plugins = Array(data.fetch("plugins", DEFAULTS.fetch("plugins"))).map do |entry|
|
|
608
|
-
coerce_plugin_entry(entry)
|
|
190
|
+
Coercion.coerce_plugin_entry(entry)
|
|
609
191
|
end.freeze
|
|
610
192
|
@disabled_rules = Array(data.fetch("disable", DEFAULTS.fetch("disable"))).map(&:to_s).freeze
|
|
611
193
|
@libraries = Array(data.fetch("libraries", DEFAULTS.fetch("libraries"))).map(&:to_s).freeze
|
|
612
194
|
sig_paths = data.fetch("signature_paths", DEFAULTS.fetch("signature_paths"))
|
|
613
195
|
@signature_paths = sig_paths.nil? ? nil : Array(sig_paths).map(&:to_s).freeze
|
|
614
|
-
@core_root = coerce_core_root(data.fetch("core_root", DEFAULTS.fetch("core_root")))
|
|
196
|
+
@core_root = Coercion.coerce_core_root(data.fetch("core_root", DEFAULTS.fetch("core_root")))
|
|
615
197
|
test_paths = data.fetch("test_paths", DEFAULTS.fetch("test_paths"))
|
|
616
198
|
@test_paths = test_paths.nil? ? nil : Array(test_paths).map(&:to_s).freeze
|
|
617
|
-
@sig_gen_inline_declared = coerce_sig_gen_inline_declared(data.fetch("sig_gen", nil))
|
|
618
|
-
@pre_eval = expand_pre_eval_entries(
|
|
199
|
+
@sig_gen_inline_declared = Coercion.coerce_sig_gen_inline_declared(data.fetch("sig_gen", nil))
|
|
200
|
+
@pre_eval = Coercion.expand_pre_eval_entries(
|
|
619
201
|
Array(data.fetch("pre_eval", DEFAULTS.fetch("pre_eval"))).map(&:to_s)
|
|
620
202
|
)
|
|
621
|
-
@baseline_path = coerce_baseline_path(data.fetch("baseline", DEFAULTS.fetch("baseline")))
|
|
203
|
+
@baseline_path = Coercion.coerce_baseline_path(data.fetch("baseline", DEFAULTS.fetch("baseline")))
|
|
622
204
|
@fold_platform_specific_paths = data.fetch(
|
|
623
205
|
"fold_platform_specific_paths", DEFAULTS.fetch("fold_platform_specific_paths")
|
|
624
206
|
)
|
|
@@ -635,24 +217,24 @@ module Rigor
|
|
|
635
217
|
@cache_path = cache.fetch("path").to_s
|
|
636
218
|
raw_max = cache.fetch("max_bytes")
|
|
637
219
|
@cache_max_bytes = raw_max.nil? ? nil : Integer(raw_max)
|
|
638
|
-
@cache_validation = coerce_cache_validation(cache.fetch("validation", "auto"))
|
|
639
|
-
@plugins_isolation = coerce_plugins_isolation(
|
|
220
|
+
@cache_validation = Coercion.coerce_cache_validation(cache.fetch("validation", "auto"))
|
|
221
|
+
@plugins_isolation = Coercion.coerce_plugins_isolation(
|
|
640
222
|
data.fetch("plugins_isolation", DEFAULTS.fetch("plugins_isolation"))
|
|
641
223
|
)
|
|
642
|
-
@plugins_io_network = coerce_network_policy(plugins_io.fetch("network"))
|
|
224
|
+
@plugins_io_network = Coercion.coerce_network_policy(plugins_io.fetch("network"))
|
|
643
225
|
@plugins_io_allowed_paths = Array(plugins_io.fetch("allowed_paths")).map(&:to_s).freeze
|
|
644
226
|
@plugins_io_allowed_url_hosts = Array(plugins_io.fetch("allowed_url_hosts")).map(&:to_s).freeze
|
|
645
|
-
@severity_profile = coerce_severity_profile(
|
|
227
|
+
@severity_profile = Coercion.coerce_severity_profile(
|
|
646
228
|
data.fetch("severity_profile", DEFAULTS.fetch("severity_profile"))
|
|
647
229
|
)
|
|
648
|
-
@severity_overrides = coerce_severity_overrides(
|
|
230
|
+
@severity_overrides = Coercion.coerce_severity_overrides(
|
|
649
231
|
data.fetch("severity_overrides", DEFAULTS.fetch("severity_overrides"))
|
|
650
232
|
)
|
|
651
233
|
@dependencies = Dependencies.from_h(
|
|
652
234
|
data.fetch("dependencies", DEFAULTS.fetch("dependencies"))
|
|
653
235
|
)
|
|
654
236
|
parallel = DEFAULTS.fetch("parallel").merge(data.fetch("parallel", {}))
|
|
655
|
-
@parallel_workers = coerce_parallel_workers(parallel.fetch("workers"))
|
|
237
|
+
@parallel_workers = Coercion.coerce_parallel_workers(parallel.fetch("workers"))
|
|
656
238
|
bundler = DEFAULTS.fetch("bundler").merge(data.fetch("bundler", {}))
|
|
657
239
|
bp = bundler.fetch("bundle_path")
|
|
658
240
|
@bundler_bundle_path = bp.nil? ? nil : bp.to_s.dup.freeze
|
|
@@ -753,7 +335,7 @@ module Rigor
|
|
|
753
335
|
# silently reverting, and the call-site cleanup can land whenever it is convenient.
|
|
754
336
|
# - An id that is in neither {BleedingEdge::FEATURES} nor {BleedingEdge::GRADUATED} **raises**. An
|
|
755
337
|
# unknown id in a *config file* stays inert on purpose (it may come from a newer gem — see
|
|
756
|
-
# {
|
|
338
|
+
# {Coercion.coerce_bleeding_edge}), but an id here is written by a Rigor contributor against the registry in
|
|
757
339
|
# the same checkout: a typo is a bug, and reading it as `false` would ship the feature permanently off
|
|
758
340
|
# with no signal.
|
|
759
341
|
#
|
|
@@ -774,7 +356,7 @@ module Rigor
|
|
|
774
356
|
# `bleeding_edge_severity_overrides` the two {SeverityProfile.resolve} sites consult) is replaced by
|
|
775
357
|
# `value`, leaving every other field shared with the receiver. `value` takes the same forms as the
|
|
776
358
|
# `bleeding_edge:` config key — `false` / `true` / a feature-id Array / `{ "all" => true, "except" =>
|
|
777
|
-
# [...] }` — and is normalised through the same {
|
|
359
|
+
# [...] }` — and is normalised through the same {Coercion.coerce_bleeding_edge} path, so an unknown id stays
|
|
778
360
|
# inert.
|
|
779
361
|
#
|
|
780
362
|
# The CLI's `--bleeding-edge[=ids]` / `--no-bleeding-edge` flag uses this to override the configured
|
|
@@ -851,7 +433,7 @@ module Rigor
|
|
|
851
433
|
# {#bleeding_edge_active?} predicate and the severity resolution read. `#initialize` and
|
|
852
434
|
# {#with_bleeding_edge} both call this, so there is one derivation to keep in step.
|
|
853
435
|
def derive_bleeding_edge(value)
|
|
854
|
-
@bleeding_edge = coerce_bleeding_edge(value)
|
|
436
|
+
@bleeding_edge = Coercion.coerce_bleeding_edge(value)
|
|
855
437
|
@bleeding_edge_severity_overrides = BleedingEdge.severity_overrides_for(@bleeding_edge)
|
|
856
438
|
@bleeding_edge_active_ids = BleedingEdge.active_ids_for(@bleeding_edge)
|
|
857
439
|
end
|
|
@@ -868,8 +450,8 @@ module Rigor
|
|
|
868
450
|
# ADR-103 WD13 — the `effects:` block, or nil when the key is absent or explicitly `false`. A
|
|
869
451
|
# present-but-empty key (`effects:` alone, which YAML parses as nil) and `effects: {}` are the same
|
|
870
452
|
# thing: collection on, every sub-key defaulted. A non-Hash body is normalised to `{}` rather than
|
|
871
|
-
# rejected
|
|
872
|
-
#
|
|
453
|
+
# rejected here: tier 1 (the schema) is where the body's shape is answered, and each sub-key reader
|
|
454
|
+
# below validates its own value.
|
|
873
455
|
#
|
|
874
456
|
# ADR-103 WD15 — a loaded file that carries no `effects:` key AT ALL (`effects_key_present == false`,
|
|
875
457
|
# so `value` can only be the `false` DEFAULTS fallback here, never a user's own explicit `false`) behaves
|
|
@@ -906,67 +488,13 @@ module Rigor
|
|
|
906
488
|
# A label that is well-formed but unknown to the *registry* is deliberately NOT rejected here — that is
|
|
907
489
|
# `effect.unknown-label`'s job (#384), and it fails open.
|
|
908
490
|
def coerce_effects_snapshot(effects)
|
|
909
|
-
@effects_check = coerce_effects_check?(effects)
|
|
491
|
+
@effects_check = Coercion.coerce_effects_check?(effects)
|
|
910
492
|
snapshot = effects&.fetch("snapshot", nil)
|
|
911
493
|
snapshot = {} unless snapshot.is_a?(Hash)
|
|
912
494
|
@effects_snapshot_path = (snapshot.fetch("path", nil) || DEFAULT_EFFECTS_SNAPSHOT_PATH).to_s.freeze
|
|
913
|
-
@effects_snapshot_reach = coerce_effects_reach(snapshot.fetch("reach", nil))
|
|
914
|
-
@effects_snapshot_gate = coerce_effects_gate(snapshot.fetch("gate", nil))
|
|
915
|
-
@effects_tolerated = coerce_effects_tolerated(effects&.fetch("tolerated", nil))
|
|
916
|
-
end
|
|
917
|
-
|
|
918
|
-
# `effects.check:` — true by default under a present block, and never true without one. Only an
|
|
919
|
-
# explicit `false` turns it off; any other value is normalised to true rather than rejected, because a
|
|
920
|
-
# switch whose only two readings are "check" and "do not check" has nothing a tier-2 error would add.
|
|
921
|
-
def coerce_effects_check?(effects)
|
|
922
|
-
return false if effects.nil?
|
|
923
|
-
|
|
924
|
-
effects.fetch("check", true) != false
|
|
925
|
-
end
|
|
926
|
-
|
|
927
|
-
VALID_EFFECTS_GATES = %i[symmetric additions].freeze
|
|
928
|
-
private_constant :VALID_EFFECTS_GATES
|
|
929
|
-
|
|
930
|
-
def coerce_effects_gate(value)
|
|
931
|
-
return :symmetric if value.nil?
|
|
932
|
-
|
|
933
|
-
gate = value.to_s.to_sym
|
|
934
|
-
unless VALID_EFFECTS_GATES.include?(gate)
|
|
935
|
-
raise ConfigurationError,
|
|
936
|
-
"effects.snapshot.gate must be one of #{VALID_EFFECTS_GATES.inspect}, got #{value.inspect}"
|
|
937
|
-
end
|
|
938
|
-
|
|
939
|
-
gate
|
|
940
|
-
end
|
|
941
|
-
|
|
942
|
-
# Entry-point globs and preset names, kept as written.
|
|
943
|
-
#
|
|
944
|
-
# **Shape only.** A preset is *named by a plugin* (#387; ADR-103 WD14) and plugins load from this very
|
|
945
|
-
# configuration, so at this point no preset is registered yet and asking `EntryPoints.known?` would
|
|
946
|
-
# reject `reach: [rails]` for every project that uses one. The existence check therefore lives where
|
|
947
|
-
# the snapshot expands `reach:` ({Effects::Snapshot.expand_reach}), which runs after plugin load and
|
|
948
|
-
# raises there — the same error, at the first moment it can be right.
|
|
949
|
-
def coerce_effects_reach(value)
|
|
950
|
-
entries = Array(value).map(&:to_s)
|
|
951
|
-
entries.each do |entry|
|
|
952
|
-
next if Effects::EntryPoints.glob?(entry) || Effects::EntryPoints.name?(entry)
|
|
953
|
-
|
|
954
|
-
raise ConfigurationError,
|
|
955
|
-
"effects.snapshot.reach entry is neither a file glob nor a well-formed entry-point preset " \
|
|
956
|
-
"name: #{entry.inspect} (a preset name is #{Effects::EntryPoints::NAME_PATTERN.inspect}; " \
|
|
957
|
-
"anything carrying a path or glob character is treated as a file glob instead)"
|
|
958
|
-
end
|
|
959
|
-
entries.uniq.freeze
|
|
960
|
-
end
|
|
961
|
-
|
|
962
|
-
# Shape validation only: the label grammar of `docs/type-specification/effect-labels.md`.
|
|
963
|
-
def coerce_effects_tolerated(value)
|
|
964
|
-
labels = Array(value).map(&:to_s)
|
|
965
|
-
labels.each do |label|
|
|
966
|
-
raise ConfigurationError, "effects.tolerated is not a well-formed effect label: #{label.inspect}" unless
|
|
967
|
-
Effects::Label.valid?(label)
|
|
968
|
-
end
|
|
969
|
-
labels.uniq.sort.freeze
|
|
495
|
+
@effects_snapshot_reach = Coercion.coerce_effects_reach(snapshot.fetch("reach", nil))
|
|
496
|
+
@effects_snapshot_gate = Coercion.coerce_effects_gate(snapshot.fetch("gate", nil))
|
|
497
|
+
@effects_tolerated = Coercion.coerce_effects_tolerated(effects&.fetch("tolerated", nil))
|
|
970
498
|
end
|
|
971
499
|
|
|
972
500
|
# ADR-103 WD5 / WD6 / #385 — the three policy keys: the project's own vocabulary (`labels:`), its
|
|
@@ -979,346 +507,9 @@ module Rigor
|
|
|
979
507
|
# well-formed but unknown to the *registry* is deliberately fine here: it fails open (⊤ for an
|
|
980
508
|
# envelope, an unregistered meaning for an attribution) and surfaces as `effect.unknown-label`.
|
|
981
509
|
def coerce_effects_policy(effects)
|
|
982
|
-
@effects_labels = coerce_effects_labels(effects&.fetch("labels", nil))
|
|
983
|
-
@effects_attribution = coerce_effects_attribution(effects&.fetch("attribution", nil))
|
|
984
|
-
@effects_envelopes = coerce_effects_envelopes(effects&.fetch("envelopes", nil))
|
|
985
|
-
end
|
|
986
|
-
|
|
987
|
-
NO_ATTRIBUTION = {}.freeze
|
|
988
|
-
private_constant :NO_ATTRIBUTION
|
|
989
|
-
|
|
990
|
-
def coerce_effects_labels(value)
|
|
991
|
-
labels = Array(value).map(&:to_s)
|
|
992
|
-
labels.each do |label|
|
|
993
|
-
raise ConfigurationError, "effects.labels is not a well-formed effect label: #{label.inspect}" unless
|
|
994
|
-
Effects::Label.valid?(label)
|
|
995
|
-
end
|
|
996
|
-
labels.uniq.sort.freeze
|
|
997
|
-
end
|
|
998
|
-
|
|
999
|
-
# `{ "Net::HTTP.get" => ["io.net.http"] }` — a method key exactly as the symbol tables spell one
|
|
1000
|
-
# (`Owner#instance`, `Owner.singleton`), mapped to the labels a call to it contributes.
|
|
1001
|
-
def coerce_effects_attribution(value)
|
|
1002
|
-
return NO_ATTRIBUTION unless value.is_a?(Hash)
|
|
1003
|
-
|
|
1004
|
-
value.each_with_object({}) do |(key, labels), out|
|
|
1005
|
-
name = key.to_s
|
|
1006
|
-
unless Effects::MethodKey.valid?(name)
|
|
1007
|
-
raise ConfigurationError,
|
|
1008
|
-
"effects.attribution key is not a method key (`Owner#method` / `Owner.method`): #{name.inspect}"
|
|
1009
|
-
end
|
|
1010
|
-
|
|
1011
|
-
out[name] = coerce_effect_label_list(Array(labels), "effects.attribution[#{name.inspect}]")
|
|
1012
|
-
end.freeze
|
|
1013
|
-
end
|
|
1014
|
-
|
|
1015
|
-
# `[{ match: | namespace:, effect: [...] }]`. Exactly one selector per entry: an entry naming both
|
|
1016
|
-
# would need a precedence rule between two selectors of the same entry, and one naming neither selects
|
|
1017
|
-
# every class in the project, which is never what an author meant to write.
|
|
1018
|
-
def coerce_effects_envelopes(value)
|
|
1019
|
-
Array(value).each_with_index.map { |entry, index| coerce_effects_envelope(entry, index) }.freeze
|
|
1020
|
-
end
|
|
1021
|
-
|
|
1022
|
-
def coerce_effects_envelope(entry, index)
|
|
1023
|
-
where = "effects.envelopes[#{index}]"
|
|
1024
|
-
raise ConfigurationError, "#{where} is not a mapping: #{entry.inspect}" unless entry.is_a?(Hash)
|
|
1025
|
-
|
|
1026
|
-
match = coerce_effects_envelope_selector(entry["match"], "#{where}.match")
|
|
1027
|
-
namespace = coerce_effects_envelope_selector(entry["namespace"], "#{where}.namespace")
|
|
1028
|
-
if match.nil? == namespace.nil?
|
|
1029
|
-
raise ConfigurationError, "#{where} must name exactly one of `match:` (a path glob) or `namespace:` " \
|
|
1030
|
-
"(a constant glob), got #{match.nil? ? 'neither' : 'both'}"
|
|
1031
|
-
end
|
|
1032
|
-
unless entry.key?("effect")
|
|
1033
|
-
raise ConfigurationError, "#{where} has no `effect:` bound (write `effect: []` for the empty envelope)"
|
|
1034
|
-
end
|
|
1035
|
-
|
|
1036
|
-
{
|
|
1037
|
-
"match" => match, "namespace" => namespace,
|
|
1038
|
-
"effect" => coerce_effect_label_list(Array(entry["effect"]), "#{where}.effect")
|
|
1039
|
-
}.freeze
|
|
1040
|
-
end
|
|
1041
|
-
|
|
1042
|
-
def coerce_effects_envelope_selector(value, where)
|
|
1043
|
-
return nil if value.nil?
|
|
1044
|
-
|
|
1045
|
-
selector = value.to_s
|
|
1046
|
-
raise ConfigurationError, "#{where} is empty" if selector.strip.empty?
|
|
1047
|
-
|
|
1048
|
-
selector.freeze
|
|
1049
|
-
end
|
|
1050
|
-
|
|
1051
|
-
def coerce_effect_label_list(labels, where)
|
|
1052
|
-
labels.map(&:to_s).each do |label|
|
|
1053
|
-
raise ConfigurationError, "#{where} is not a well-formed effect label: #{label.inspect}" unless
|
|
1054
|
-
Effects::Label.valid?(label)
|
|
1055
|
-
end.uniq.sort.freeze
|
|
1056
|
-
end
|
|
1057
|
-
|
|
1058
|
-
# ADR-17 slice 4 — `pre_eval:` glob expansion. Each entry is accepted as either a literal path (slice 1
|
|
1059
|
-
# contract) OR a `File.fnmatch?`-shaped glob pattern (`lib/core_ext/**/*.rb`). Glob meta characters (`*`,
|
|
1060
|
-
# `?`, `[`) trigger `Dir.glob` expansion; the resulting file list is folded into the `pre_eval:` set with
|
|
1061
|
-
# `uniq`. Literal entries that don't exist on disk continue to surface as `pre-eval.file-not-found`
|
|
1062
|
-
# `:error` (slice 1 behaviour); glob entries that match nothing degrade silently to "no contribution from
|
|
1063
|
-
# this entry" so a templated `**` pattern in a fresh project doesn't generate an error per match-less
|
|
1064
|
-
# pattern.
|
|
1065
|
-
def expand_pre_eval_entries(entries)
|
|
1066
|
-
entries.flat_map { |entry| expand_pre_eval_entry(entry) }.uniq.freeze
|
|
1067
|
-
end
|
|
1068
|
-
|
|
1069
|
-
# #1956 — a relative entry arrives joined onto the config file's directory, so the metacharacters the
|
|
1070
|
-
# check above sees may be that directory's own (`ds [x]/`). The leading run of segments that name existing
|
|
1071
|
-
# directories is read literally and only the rest is globbed under it: a literal entry under such a
|
|
1072
|
-
# directory stays a literal path, and a pattern matches what it matches under a plain directory.
|
|
1073
|
-
def expand_pre_eval_entry(entry)
|
|
1074
|
-
return [entry] unless glob_pattern?(entry)
|
|
1075
|
-
|
|
1076
|
-
base, pattern = literal_directory_prefix(entry)
|
|
1077
|
-
return [entry] unless glob_pattern?(pattern)
|
|
1078
|
-
|
|
1079
|
-
base ? RootedGlob.glob(base, pattern) : Dir.glob(entry, sort: true)
|
|
1080
|
-
end
|
|
1081
|
-
|
|
1082
|
-
def literal_directory_prefix(entry)
|
|
1083
|
-
segments = entry.split("/")
|
|
1084
|
-
count = (1...segments.size).take_while { |n| File.directory?(join_segments(segments.take(n))) }.size
|
|
1085
|
-
return [nil, entry] if count.zero?
|
|
1086
|
-
|
|
1087
|
-
[join_segments(segments.take(count)), segments.drop(count).join("/")]
|
|
1088
|
-
end
|
|
1089
|
-
|
|
1090
|
-
# `"/a".split("/")` leads with an empty segment, which spells the filesystem root.
|
|
1091
|
-
def join_segments(segments)
|
|
1092
|
-
path = segments.join("/")
|
|
1093
|
-
path.empty? ? "/" : path
|
|
1094
|
-
end
|
|
1095
|
-
|
|
1096
|
-
def glob_pattern?(path)
|
|
1097
|
-
path.include?("*") || path.include?("?") || path.include?("[")
|
|
1098
|
-
end
|
|
1099
|
-
|
|
1100
|
-
# Accepts either `"rigor-foo"` (gem-name shorthand) or `{ "gem" => "rigor-foo", "id" => "foo", "config" =>
|
|
1101
|
-
# {...} }` (full form). Returns the canonical hash form so the loader works against a single shape.
|
|
1102
|
-
def coerce_plugin_entry(entry)
|
|
1103
|
-
case entry
|
|
1104
|
-
when String
|
|
1105
|
-
entry.dup.freeze
|
|
1106
|
-
when Hash
|
|
1107
|
-
entry.to_h { |k, v| [k.to_s, v] }.freeze
|
|
1108
|
-
else
|
|
1109
|
-
raise ConfigurationError,
|
|
1110
|
-
"plugin configuration entry must be a String or Hash, got #{entry.inspect}"
|
|
1111
|
-
end
|
|
1112
|
-
end
|
|
1113
|
-
|
|
1114
|
-
# `target_ruby` is passed as Prism's `version:` option at the analyser's parse sites
|
|
1115
|
-
# (`Analysis::Runner`, `CLI::TypeOfCommand`, `CLI::TypeScanCommand`) so projects that target an older
|
|
1116
|
-
# Ruby get parse errors for syntax their target doesn't support. Format validation here is loose —
|
|
1117
|
-
# accepts any `<major>.<minor>` or `<major>.<minor>.<patch>` form, plus the literal `"latest"`. Prism
|
|
1118
|
-
# itself enforces the supported set and raises `ArgumentError` for versions it does not recognise (e.g.
|
|
1119
|
-
# `"1.0"`); the parse-time error message names the version, so the user can correct the setting.
|
|
1120
|
-
TARGET_RUBY_FORMAT = /\A(?:\d+\.\d+(?:\.\d+)?|latest)\z/
|
|
1121
|
-
private_constant :TARGET_RUBY_FORMAT
|
|
1122
|
-
|
|
1123
|
-
def coerce_target_ruby(value)
|
|
1124
|
-
s = value.to_s
|
|
1125
|
-
unless s.match?(TARGET_RUBY_FORMAT)
|
|
1126
|
-
raise ConfigurationError,
|
|
1127
|
-
"target_ruby must be a version (e.g. \"3.4\", \"4.0\", \"3.4.0\") or \"latest\", got #{value.inspect}"
|
|
1128
|
-
end
|
|
1129
|
-
|
|
1130
|
-
s.dup.freeze
|
|
1131
|
-
end
|
|
1132
|
-
|
|
1133
|
-
# YAML scalar may arrive as a String or already as a Symbol; coerce to the canonical Symbol shape so the
|
|
1134
|
-
# downstream `TrustPolicy` constructor stays strict.
|
|
1135
|
-
#
|
|
1136
|
-
# The accepted set is duplicated from {Rigor::Plugin::TrustPolicy::VALID_NETWORK_POLICIES} so
|
|
1137
|
-
# `Configuration` does not require the plugin namespace at load time (Configuration is loaded before
|
|
1138
|
-
# Plugin in `lib/rigor.rb`); the two stay in lockstep via spec.
|
|
1139
|
-
VALID_NETWORK_POLICIES = %i[disabled allowlist].freeze
|
|
1140
|
-
private_constant :VALID_NETWORK_POLICIES
|
|
1141
|
-
|
|
1142
|
-
# ADR-15 Phase 4c — accepts a non-negative Integer (or a string-shaped one from YAML files that miss type
|
|
1143
|
-
# annotations). Negative / non-integer values raise so typos / bad YAML fail loudly rather than silently
|
|
1144
|
-
# disabling parallelism.
|
|
1145
|
-
def coerce_parallel_workers(value)
|
|
1146
|
-
integer = Integer(value)
|
|
1147
|
-
raise ConfigurationError, "parallel.workers must be >= 0, got #{value.inspect}" if integer.negative?
|
|
1148
|
-
|
|
1149
|
-
integer
|
|
1150
|
-
rescue TypeError, ArgumentError => e
|
|
1151
|
-
raise ConfigurationError, "parallel.workers must be a non-negative Integer, got #{value.inspect} (#{e.message})"
|
|
1152
|
-
end
|
|
1153
|
-
|
|
1154
|
-
# ADR-22 WD2 (b) — `baseline: <path>` activates the file; `baseline: false` is the explicit-disable form
|
|
1155
|
-
# (useful in `.rigor.yml` to override an upstream `.rigor.dist.yml` that names a baseline). `nil`
|
|
1156
|
-
# (default / absent key) is also "no baseline".
|
|
1157
|
-
# Issue #2517 — the directory's existence and contents are checked where the environment is built
|
|
1158
|
-
# ({Environment::CoreRoot.validate!}), not here: `rigor init`, `rigor doctor` and the language server's reload
|
|
1159
|
-
# load a configuration without building an environment, and must still be able to read one naming a core that
|
|
1160
|
-
# is not generated yet.
|
|
1161
|
-
def coerce_core_root(value)
|
|
1162
|
-
return nil if value.nil?
|
|
1163
|
-
raise ConfigurationError, "core_root must be a directory path, got #{value.inspect}" unless value.is_a?(String)
|
|
1164
|
-
raise ConfigurationError, "core_root must not be empty" if value.strip.empty?
|
|
1165
|
-
|
|
1166
|
-
value.dup.freeze
|
|
1167
|
-
end
|
|
1168
|
-
|
|
1169
|
-
def coerce_baseline_path(value)
|
|
1170
|
-
return nil if value.nil? || value == false
|
|
1171
|
-
|
|
1172
|
-
value.to_s
|
|
1173
|
-
end
|
|
1174
|
-
|
|
1175
|
-
# ADR-87 WD1 — `cache.validation` is `"auto"` (default), `"stat"`, or `"digest"`. An unrecognised value
|
|
1176
|
-
# fails soft to the default rather than aborting a check over a typo — the strict `"digest"` behaviour is
|
|
1177
|
-
# the safe fallback either way, and the always-available `RIGOR_STRICT_VALIDATION=1` env escape hatch does
|
|
1178
|
-
# not depend on this value being valid.
|
|
1179
|
-
VALID_CACHE_VALIDATIONS = %w[auto stat digest].freeze
|
|
1180
|
-
private_constant :VALID_CACHE_VALIDATIONS
|
|
1181
|
-
|
|
1182
|
-
# The `sig_gen.inline_declared:` values, as the Symbols {#sig_gen_inline_declared} answers.
|
|
1183
|
-
VALID_SIG_GEN_INLINE_DECLARED = %w[write skip].freeze
|
|
1184
|
-
private_constant :VALID_SIG_GEN_INLINE_DECLARED
|
|
1185
|
-
|
|
1186
|
-
# Rejects rather than fails soft: an unrecognised value read as `write` would put a second declaration of
|
|
1187
|
-
# every inline-annotated method into `sig/` for exactly the project that asked for none. A `sig_gen:`
|
|
1188
|
-
# block that omits the key, or is written empty, keeps the default.
|
|
1189
|
-
def coerce_sig_gen_inline_declared(section)
|
|
1190
|
-
section = {} if section.nil?
|
|
1191
|
-
raise ConfigurationError, "sig_gen must be a mapping, got #{section.inspect}" unless section.is_a?(Hash)
|
|
1192
|
-
|
|
1193
|
-
# The schema closes this object (`additionalProperties: false`); a misspelled key here would otherwise
|
|
1194
|
-
# load as the default and write exactly what `inline_declare: skip` was meant to prevent.
|
|
1195
|
-
unknown = section.keys.map(&:to_s) - DEFAULTS.fetch("sig_gen").keys
|
|
1196
|
-
unless unknown.empty?
|
|
1197
|
-
raise ConfigurationError,
|
|
1198
|
-
"sig_gen has unknown key(s) #{unknown.inspect}; known keys: #{DEFAULTS.fetch('sig_gen').keys.inspect}"
|
|
1199
|
-
end
|
|
1200
|
-
|
|
1201
|
-
value = section.fetch("inline_declared", DEFAULTS.dig("sig_gen", "inline_declared")).to_s
|
|
1202
|
-
unless VALID_SIG_GEN_INLINE_DECLARED.include?(value)
|
|
1203
|
-
raise ConfigurationError,
|
|
1204
|
-
"sig_gen.inline_declared must be one of #{VALID_SIG_GEN_INLINE_DECLARED.inspect}, " \
|
|
1205
|
-
"got #{section['inline_declared'].inspect}"
|
|
1206
|
-
end
|
|
1207
|
-
|
|
1208
|
-
value.to_sym
|
|
1209
|
-
end
|
|
1210
|
-
|
|
1211
|
-
def coerce_cache_validation(value)
|
|
1212
|
-
str = value.to_s
|
|
1213
|
-
VALID_CACHE_VALIDATIONS.include?(str) ? str : "auto"
|
|
1214
|
-
end
|
|
1215
|
-
|
|
1216
|
-
# Rejects rather than fails soft — a strategy that silently resolves to a different one is exactly
|
|
1217
|
-
# the failure #911 exists to close, and the run's isolation is not a detail the user can be assumed
|
|
1218
|
-
# not to have meant.
|
|
1219
|
-
def coerce_plugins_isolation(value)
|
|
1220
|
-
return nil if value.nil?
|
|
1221
|
-
|
|
1222
|
-
str = value.to_s
|
|
1223
|
-
return str if CONFIGURABLE_PLUGIN_ISOLATIONS.include?(str)
|
|
1224
|
-
|
|
1225
|
-
if str == "ruby_box"
|
|
1226
|
-
raise ConfigurationError,
|
|
1227
|
-
"plugins_isolation: ruby_box cannot be selected from the configuration file — `Ruby::Box` " \
|
|
1228
|
-
"must be active before Ruby boots. Run rigor with RIGOR_PLUGIN_ISOLATION=ruby_box instead " \
|
|
1229
|
-
"(the launcher re-execs itself with RUBY_BOX=1 set)."
|
|
1230
|
-
end
|
|
1231
|
-
|
|
1232
|
-
raise ConfigurationError,
|
|
1233
|
-
"plugins_isolation must be one of #{CONFIGURABLE_PLUGIN_ISOLATIONS.inspect} " \
|
|
1234
|
-
"(`ruby_box` is environment-only), got #{value.inspect}"
|
|
1235
|
-
end
|
|
1236
|
-
|
|
1237
|
-
def coerce_network_policy(value)
|
|
1238
|
-
sym = value.to_sym
|
|
1239
|
-
unless VALID_NETWORK_POLICIES.include?(sym)
|
|
1240
|
-
raise ConfigurationError,
|
|
1241
|
-
"plugins_io.network must be one of #{VALID_NETWORK_POLICIES.inspect}, got #{value.inspect}"
|
|
1242
|
-
end
|
|
1243
|
-
|
|
1244
|
-
sym
|
|
1245
|
-
end
|
|
1246
|
-
|
|
1247
|
-
# ADR-8 § "Severity profile" — accepts the canonical Symbol form or its String spelling; rejects unknown
|
|
1248
|
-
# profile names so typos fail loudly.
|
|
1249
|
-
def coerce_severity_profile(value)
|
|
1250
|
-
sym = value.to_sym
|
|
1251
|
-
unless SeverityProfile::VALID_PROFILES.include?(sym)
|
|
1252
|
-
raise ConfigurationError,
|
|
1253
|
-
"severity_profile must be one of " \
|
|
1254
|
-
"#{SeverityProfile::VALID_PROFILES.inspect}, got #{value.inspect}"
|
|
1255
|
-
end
|
|
1256
|
-
|
|
1257
|
-
sym
|
|
1258
|
-
end
|
|
1259
|
-
|
|
1260
|
-
# ADR-8 § "Severity profile" — `severity_overrides:` is a `{ rule => severity }` map. Keys are canonical
|
|
1261
|
-
# rule ids (`call.undefined-method`) or family wildcards (`call`). Values are
|
|
1262
|
-
# {SeverityProfile::VALID_SEVERITIES} symbols (`:error` / `:warning` / `:info` / `:off`). Unknown
|
|
1263
|
-
# severities raise; unknown rule ids are silently kept (the override is inert until the rule lands).
|
|
1264
|
-
def coerce_severity_overrides(value)
|
|
1265
|
-
raise ConfigurationError, "severity_overrides must be a Hash, got #{value.inspect}" unless value.is_a?(Hash)
|
|
1266
|
-
|
|
1267
|
-
value.to_h do |k, v|
|
|
1268
|
-
# YAML 1.1 parses bare `off`/`on`/`no`/`yes`/`true`/`false` as booleans, so a user who wrote `off` (a
|
|
1269
|
-
# valid severity) without quotes hands us `false`. Catch the non-Symbol / non-String case before
|
|
1270
|
-
# `to_sym` blows up with a backtrace.
|
|
1271
|
-
unless v.is_a?(String) || v.is_a?(Symbol)
|
|
1272
|
-
hint = v == false ? %( — did you mean the string "off"?) : ""
|
|
1273
|
-
raise ConfigurationError,
|
|
1274
|
-
"severity_overrides[#{k.inspect}] is #{v.inspect}, a YAML boolean#{hint} " \
|
|
1275
|
-
"Bare off/on/no/yes/true/false are parsed as booleans; quote the severity " \
|
|
1276
|
-
"(e.g. \"off\")."
|
|
1277
|
-
end
|
|
1278
|
-
|
|
1279
|
-
sym = v.to_sym
|
|
1280
|
-
unless SeverityProfile::VALID_SEVERITIES.include?(sym)
|
|
1281
|
-
raise ConfigurationError,
|
|
1282
|
-
"severity_overrides[#{k.inspect}] must be one of " \
|
|
1283
|
-
"#{SeverityProfile::VALID_SEVERITIES.inspect}, got #{v.inspect}"
|
|
1284
|
-
end
|
|
1285
|
-
|
|
1286
|
-
[k.to_s, sym]
|
|
1287
|
-
end.freeze
|
|
1288
|
-
end
|
|
1289
|
-
|
|
1290
|
-
# ADR-50 § WD2 — normalizes the `bleeding_edge:` selector to a canonical `{ "mode" => … }` hash
|
|
1291
|
-
# (interpreted by {Rigor::BleedingEdge}). Validates *shape* only; membership against the overlay is
|
|
1292
|
-
# intentionally NOT checked here (an unknown id stays inert, like an unknown `severity_overrides:` rule).
|
|
1293
|
-
# Deep-frozen so the Configuration stays `Ractor.shareable?`.
|
|
1294
|
-
def coerce_bleeding_edge(value)
|
|
1295
|
-
case value
|
|
1296
|
-
when nil, false then { "mode" => "none" }
|
|
1297
|
-
when true then { "mode" => "all" }
|
|
1298
|
-
when Array then { "mode" => "list", "ids" => freeze_ids(value) }
|
|
1299
|
-
when Hash then coerce_bleeding_edge_hash(value)
|
|
1300
|
-
else
|
|
1301
|
-
raise ConfigurationError,
|
|
1302
|
-
"bleeding_edge must be true, false, a list of feature ids, " \
|
|
1303
|
-
"or { all: true, except: [...] }, got #{value.inspect}"
|
|
1304
|
-
end.freeze
|
|
1305
|
-
end
|
|
1306
|
-
|
|
1307
|
-
def coerce_bleeding_edge_hash(value)
|
|
1308
|
-
hash = value.to_h { |k, v| [k.to_s, v] }
|
|
1309
|
-
if hash.fetch("all", false) == true
|
|
1310
|
-
{ "mode" => "all", "except" => freeze_ids(Array(hash["except"])) }
|
|
1311
|
-
else
|
|
1312
|
-
{ "mode" => "none" }
|
|
1313
|
-
end
|
|
1314
|
-
end
|
|
1315
|
-
|
|
1316
|
-
# Feature ids reach `coerce_bleeding_edge` from YAML, a `to_h` round-trip, or the CLI's
|
|
1317
|
-
# `--bleeding-edge=a,b` (all runtime-created, non-frozen Strings). Each id String is frozen so the
|
|
1318
|
-
# normalized selector — and thus the whole Configuration — stays deeply frozen and `Ractor.shareable?`
|
|
1319
|
-
# for the worker path (the same invariant `#initialize`'s final `freeze` upholds for every other field).
|
|
1320
|
-
def freeze_ids(ids)
|
|
1321
|
-
ids.map { |id| id.to_s.dup.freeze }.freeze
|
|
510
|
+
@effects_labels = Coercion.coerce_effects_labels(effects&.fetch("labels", nil))
|
|
511
|
+
@effects_attribution = Coercion.coerce_effects_attribution(effects&.fetch("attribution", nil))
|
|
512
|
+
@effects_envelopes = Coercion.coerce_effects_envelopes(effects&.fetch("envelopes", nil))
|
|
1322
513
|
end
|
|
1323
514
|
|
|
1324
515
|
# Renders the normalized selector back into the user-facing `bleeding_edge:` form for `#to_h`
|