henitai 0.5.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +332 -1
  3. data/README.md +123 -19
  4. data/assets/schema/henitai.schema.json +26 -0
  5. data/lib/henitai/arid_node_filter.rb +4 -19
  6. data/lib/henitai/bootstrap_error_message.rb +38 -0
  7. data/lib/henitai/canonical_report_merger.rb +23 -2
  8. data/lib/henitai/checkpoint_reporter.rb +5 -0
  9. data/lib/henitai/cli/operator_command.rb +10 -3
  10. data/lib/henitai/cli/run_command.rb +25 -7
  11. data/lib/henitai/cli/run_options.rb +1 -1
  12. data/lib/henitai/cli.rb +6 -2
  13. data/lib/henitai/composite_progress_reporter.rb +15 -2
  14. data/lib/henitai/configuration.rb +9 -1
  15. data/lib/henitai/configuration_validator/rules.rb +9 -0
  16. data/lib/henitai/configuration_validator/scalars.rb +22 -0
  17. data/lib/henitai/configuration_validator.rb +4 -2
  18. data/lib/henitai/constant_path.rb +48 -0
  19. data/lib/henitai/control_gate.rb +78 -0
  20. data/lib/henitai/control_run.rb +67 -0
  21. data/lib/henitai/coverage_bootstrapper.rb +46 -11
  22. data/lib/henitai/coverage_formatter.rb +26 -3
  23. data/lib/henitai/coverage_report_reader.rb +21 -0
  24. data/lib/henitai/equivalence_detector/operand_predicates.rb +16 -0
  25. data/lib/henitai/equivalence_detector.rb +46 -38
  26. data/lib/henitai/example_summary.rb +24 -0
  27. data/lib/henitai/execution_engine/env_scope.rb +3 -3
  28. data/lib/henitai/execution_engine/fork_server_scope.rb +57 -0
  29. data/lib/henitai/execution_engine.rb +109 -119
  30. data/lib/henitai/execution_provenance.rb +67 -0
  31. data/lib/henitai/fidelity_check.rb +173 -0
  32. data/lib/henitai/flaky_detection_baseline.rb +63 -0
  33. data/lib/henitai/flaky_retry_decision.rb +23 -0
  34. data/lib/henitai/flaky_test_registry.rb +63 -0
  35. data/lib/henitai/fork_server/client.rb +222 -0
  36. data/lib/henitai/fork_server/group_killer.rb +48 -0
  37. data/lib/henitai/fork_server/launcher.rb +38 -0
  38. data/lib/henitai/fork_server/mutant_runner.rb +110 -0
  39. data/lib/henitai/fork_server/protocol.rb +73 -0
  40. data/lib/henitai/fork_server/reaper.rb +24 -0
  41. data/lib/henitai/fork_server/runtime.rb +109 -0
  42. data/lib/henitai/fork_server/server.rb +108 -0
  43. data/lib/henitai/fork_server/server_process.rb +73 -0
  44. data/lib/henitai/fork_server/status.rb +52 -0
  45. data/lib/henitai/fork_server.rb +42 -0
  46. data/lib/henitai/generated_artifacts.rb +3 -0
  47. data/lib/henitai/git_diff_analyzer.rb +28 -11
  48. data/lib/henitai/history_checkpointer.rb +72 -0
  49. data/lib/henitai/incremental_filter.rb +20 -10
  50. data/lib/henitai/integration/base.rb +78 -19
  51. data/lib/henitai/integration/capped_log_sink.rb +34 -0
  52. data/lib/henitai/integration/child_bootstrap.rb +7 -0
  53. data/lib/henitai/integration/child_report_store.rb +65 -0
  54. data/lib/henitai/integration/minitest.rb +8 -13
  55. data/lib/henitai/integration/minitest_autorun.rb +20 -0
  56. data/lib/henitai/integration/minitest_fail_fast.rb +43 -0
  57. data/lib/henitai/integration/minitest_outcome_reporter.rb +44 -0
  58. data/lib/henitai/integration/minitest_preload.rb +30 -0
  59. data/lib/henitai/integration/minitest_runnable_filter.rb +61 -0
  60. data/lib/henitai/integration/minitest_test_runner.rb +47 -18
  61. data/lib/henitai/integration/mutant_run_support.rb +80 -17
  62. data/lib/henitai/integration/rspec_child_runner.rb +49 -9
  63. data/lib/henitai/integration/rspec_file_order.rb +37 -0
  64. data/lib/henitai/integration/rspec_preload.rb +35 -0
  65. data/lib/henitai/integration/rspec_process_runner.rb +4 -20
  66. data/lib/henitai/integration/scenario_log_support.rb +31 -18
  67. data/lib/henitai/integration.rb +18 -6
  68. data/lib/henitai/kill_history/store.rb +67 -0
  69. data/lib/henitai/kill_history.rb +85 -0
  70. data/lib/henitai/minitest_coverage_reporter.rb +22 -6
  71. data/lib/henitai/minitest_result_file.rb +62 -0
  72. data/lib/henitai/mutant/activation.rb +32 -0
  73. data/lib/henitai/mutant/activator.rb +75 -55
  74. data/lib/henitai/mutant/def_injection.rb +136 -0
  75. data/lib/henitai/mutant/lexical_scope_check.rb +120 -0
  76. data/lib/henitai/mutant/lexical_target.rb +105 -0
  77. data/lib/henitai/mutant/replacement.rb +52 -0
  78. data/lib/henitai/mutant.rb +32 -8
  79. data/lib/henitai/mutant_generator.rb +62 -18
  80. data/lib/henitai/mutant_history_store/database.rb +61 -0
  81. data/lib/henitai/mutant_history_store/sql.rb +9 -3
  82. data/lib/henitai/mutant_history_store/subject_scans.rb +101 -0
  83. data/lib/henitai/mutant_history_store/verdict_cache.rb +48 -18
  84. data/lib/henitai/mutant_history_store.rb +77 -51
  85. data/lib/henitai/mutant_identity.rb +5 -1
  86. data/lib/henitai/mutant_verdict.rb +71 -0
  87. data/lib/henitai/operator.rb +6 -2
  88. data/lib/henitai/operators/array_declaration.rb +4 -0
  89. data/lib/henitai/operators/assignment_expression.rb +2 -0
  90. data/lib/henitai/operators/conditional_expression.rb +21 -1
  91. data/lib/henitai/operators/equality_identity_operator.rb +2 -2
  92. data/lib/henitai/operators/hash_key_type.rb +11 -1
  93. data/lib/henitai/operators/hash_literal.rb +37 -9
  94. data/lib/henitai/operators/method_expression.rb +14 -3
  95. data/lib/henitai/operators/regex_metacharacters.rb +89 -0
  96. data/lib/henitai/operators/regex_mutator.rb +23 -28
  97. data/lib/henitai/operators/return_value.rb +1 -1
  98. data/lib/henitai/operators/string_literal.rb +17 -4
  99. data/lib/henitai/operators.rb +1 -0
  100. data/lib/henitai/per_test_coverage.rb +11 -7
  101. data/lib/henitai/per_test_coverage_collector.rb +30 -31
  102. data/lib/henitai/per_test_coverage_delta.rb +60 -0
  103. data/lib/henitai/per_test_coverage_selector.rb +26 -13
  104. data/lib/henitai/process_wakeup.rb +8 -3
  105. data/lib/henitai/process_worker_runner.rb +41 -7
  106. data/lib/henitai/reporter.rb +15 -8
  107. data/lib/henitai/result.rb +32 -16
  108. data/lib/henitai/reuse_context.rb +52 -0
  109. data/lib/henitai/rspec_coverage_formatter.rb +4 -0
  110. data/lib/henitai/rspec_outcomes.rb +74 -0
  111. data/lib/henitai/runner.rb +112 -21
  112. data/lib/henitai/runner_dependencies.rb +44 -3
  113. data/lib/henitai/sampling_strategy.rb +36 -6
  114. data/lib/henitai/scenario_execution_result.rb +51 -5
  115. data/lib/henitai/signal_deferral.rb +25 -0
  116. data/lib/henitai/signature_line.rb +21 -0
  117. data/lib/henitai/slot_scheduler/control_slots.rb +58 -0
  118. data/lib/henitai/slot_scheduler/draining.rb +35 -6
  119. data/lib/henitai/slot_scheduler/process_control.rb +33 -0
  120. data/lib/henitai/slot_scheduler/retry_policy.rb +20 -6
  121. data/lib/henitai/slot_scheduler.rb +64 -21
  122. data/lib/henitai/source_file_selection.rb +1 -1
  123. data/lib/henitai/source_parser.rb +29 -9
  124. data/lib/henitai/static_filter.rb +45 -14
  125. data/lib/henitai/stillborn_filter.rb +70 -2
  126. data/lib/henitai/subject.rb +8 -3
  127. data/lib/henitai/subject_resolver.rb +65 -31
  128. data/lib/henitai/suite_boot_clock.rb +48 -0
  129. data/lib/henitai/survivor_activation_cache.rb +18 -11
  130. data/lib/henitai/survivor_rerun_strategy.rb +47 -43
  131. data/lib/henitai/test_file_outcomes.rb +93 -0
  132. data/lib/henitai/test_prioritizer.rb +10 -2
  133. data/lib/henitai/timeout_calibrator.rb +31 -9
  134. data/lib/henitai/timeout_ceiling.rb +37 -0
  135. data/lib/henitai/verdict_fingerprint.rb +29 -30
  136. data/lib/henitai/version.rb +1 -1
  137. data/lib/henitai.rb +21 -1
  138. data/sig/configuration_validator.rbs +1 -0
  139. data/sig/henitai.rbs +254 -56
  140. metadata +63 -5
  141. data/lib/henitai/survivor_test_filter.rb +0 -72
data/sig/henitai.rbs CHANGED
@@ -128,14 +128,42 @@ module Henitai
128
128
  def pause: (Float) -> void
129
129
  end
130
130
 
131
+ module Integration::RspecPreload
132
+ def fork_server_supported?: () -> bool
133
+ def preload_environment: (Array[String]) -> untyped
134
+ end
135
+
136
+ module Integration::MinitestPreload
137
+ def fork_server_supported?: () -> bool
138
+ def preload_environment: (Array[String]) -> untyped
139
+ end
140
+
131
141
  module Integration::RspecChildRunner
132
142
  private
133
143
 
134
- def run_rspec_runner: (Array[String]) -> untyped
144
+ def run_rspec_runner: (Array[String]) ?{ () -> untyped } -> untyped
135
145
  def build_rspec_runner: () -> untyped
136
146
  def configure_rspec_runner: (untyped) -> void
137
147
  def load_rspec_spec_files: (Array[String]) -> void
138
- def run_rspec_specs: (untyped) -> untyped
148
+ def run_rspec_specs: (untyped, untyped) -> untyped
149
+ end
150
+
151
+ module RspecOutcomes
152
+ EVENTS: Array[Symbol]
153
+ HOOK_ERROR: String
154
+
155
+ def self.record: (TestFileOutcomes, untyped) -> void
156
+ def self.register: (TestFileOutcomes, untyped) -> void
157
+ def self.group_file: (untyped) -> String
158
+ end
159
+
160
+ class RspecOutcomes::Listener
161
+ def initialize: (TestFileOutcomes) -> void
162
+ def example_finished: (untyped) -> void
163
+ def example_group_started: (untyped) -> void
164
+ def example_group_finished: (untyped) -> void
165
+ def message: (untyped) -> void
166
+ def dump_summary: (untyped) -> void
139
167
  end
140
168
 
141
169
  module Integration::RspecTestSelection
@@ -170,6 +198,7 @@ module Henitai
170
198
  DEFAULT_MAX_FLAKY_RETRIES: Integer
171
199
  DEFAULT_MAX_LOG_BYTES: Integer
172
200
  DEFAULT_MAX_TIMEOUT: Float
201
+ DEFAULT_SUITE_TIMEOUT: Float
173
202
  DEFAULT_CHECKPOINT_EVERY: Integer
174
203
  DEFAULT_CHECKPOINT_INTERVAL: Float
175
204
  DEFAULT_REPORTS_DIR: String
@@ -187,8 +216,12 @@ module Henitai
187
216
  attr_reader ignore_patterns: Array[untyped]
188
217
  attr_reader max_mutants_per_line: Integer
189
218
  attr_reader max_flaky_retries: Integer
219
+ attr_reader control_runs: bool
220
+ attr_reader flaky_detection: bool
221
+ attr_reader fork_server: bool
190
222
  attr_reader max_log_bytes: Integer
191
223
  attr_reader max_timeout: Float
224
+ attr_reader suite_timeout: Float
192
225
  attr_reader sampling: untyped
193
226
  attr_reader jobs: untyped
194
227
  attr_reader coverage_criteria: Hash[Symbol, untyped]
@@ -227,9 +260,15 @@ module Henitai
227
260
  attr_reader stderr: String
228
261
  attr_reader exit_status: Integer?
229
262
  attr_reader log_path: String
263
+ attr_reader status_reason: String?
264
+ attr_reader killing_tests: Array[String]
265
+ attr_reader hanging_test: String?
230
266
 
231
267
  def self.build: (wait_result: untyped, stdout: String?, stderr: String?, log_path: String) -> ScenarioExecutionResult
232
- def initialize: (status: Symbol, stdout: String?, stderr: String?, log_path: String, ?exit_status: Integer?) -> void
268
+ def self.build_for_mutant: (wait_result: untyped, report: untyped, stdout: String?, stderr: String?, log_path: String, ?running_test: String?) -> ScenarioExecutionResult
269
+ def self.copy_reason: (untyped, untyped) -> String?
270
+ def initialize: (status: Symbol, stdout: String?, stderr: String?, log_path: String, ?exit_status: Integer?, ?status_reason: String?, ?killing_tests: Array[String], ?hanging_test: String?) -> void
271
+ def release_output!: () -> self
233
272
  def survived?: () -> bool
234
273
  def killed?: () -> bool
235
274
  def timeout?: () -> bool
@@ -251,9 +290,10 @@ module Henitai
251
290
  attr_reader method_type: Symbol
252
291
  attr_reader source_file: String?
253
292
  attr_reader source_range: Range[Integer]?
293
+ attr_reader lexical_scope: Array[String]?
254
294
 
255
295
  def self.parse: (String) -> Subject
256
- def initialize: (?expression: String, ?namespace: String, ?method_name: String, ?method_type: Symbol, ?source_location: Hash[Symbol, untyped], ?ast_node: untyped) -> void
296
+ def initialize: (?expression: String, ?namespace: String, ?method_name: String, ?method_type: Symbol, ?source_location: Hash[Symbol, untyped], ?ast_node: untyped, ?lexical_scope: Array[String]?) -> void
257
297
  def expression: () -> String
258
298
  def wildcard?: () -> bool
259
299
 
@@ -281,20 +321,29 @@ module Henitai
281
321
  attr_accessor covered_by: Array[String]?
282
322
  attr_accessor tests_completed: Integer?
283
323
  attr_accessor ignore_reason: String?
324
+ attr_accessor status_reason: String?
325
+ attr_accessor identity_discriminator: String?
284
326
  attr_accessor from_cache: bool
327
+ attr_accessor retry_cut_short: bool
285
328
  attr_reader precomputed_stable_id: String?
286
- attr_reader precomputed_activation_source: String?
329
+ attr_reader precomputed_activation: untyped
330
+ attr_reader precomputed_replacement: String?
287
331
 
288
- def initialize: (subject: Subject, operator: String, nodes: Hash[Symbol, untyped], description: String, location: Hash[Symbol, untyped], ?precomputed_stable_id: String?, ?precomputed_activation_source: String?) -> void
332
+ def initialize: (subject: Subject, operator: String, nodes: Hash[Symbol, untyped], description: String, location: Hash[Symbol, untyped], ?precomputed_stable_id: String?, ?precomputed_activation: untyped, ?precomputed_replacement: String?) -> void
289
333
  def stable_id: () -> String
290
334
  def mutated_source: () -> String
291
335
  def from_cache?: () -> bool
336
+ def retry_cut_short?: () -> bool
292
337
  def killed?: () -> bool
293
338
  def survived?: () -> bool
294
339
  def pending?: () -> bool
295
340
  def ignored?: () -> bool
296
341
  def equivalent?: () -> bool
297
342
  def to_s: () -> String
343
+
344
+ private
345
+
346
+ def reset_outcome: () -> void
298
347
  end
299
348
 
300
349
  class SyntaxValidator
@@ -317,13 +366,22 @@ module Henitai
317
366
  def current_snapshot: () -> untyped
318
367
  def warn_missing_coverage: () -> void
319
368
  def new_lines: (untyped) -> Hash[String, Array[Integer]]
320
- def new_line_numbers: (untyped, untyped) -> Array[Integer]
321
- def previous_line_counts: (String) -> Array[untyped]
322
- def line_counts_for: (untyped) -> Array[untyped]
323
369
  def source_file?: (String) -> bool
324
370
  def serializable_report: () -> Hash[String, Hash[String, Array[Integer]]]
325
371
  end
326
372
 
373
+ class PerTestCoverageDelta
374
+ def executed_lines: (untyped, untyped) -> Array[Integer]
375
+
376
+ private
377
+
378
+ def counted_lines: (untyped, untyped) -> Array[Integer]
379
+ def called_method_lines: (untyped, untyped) -> Array[Integer]
380
+ def untracked_method_lines: (Array[untyped], Array[untyped]) -> Array[Integer]
381
+ def line_counts: (untyped) -> Array[untyped]
382
+ def method_counts: (untyped) -> Hash[untyped, untyped]
383
+ end
384
+
327
385
  class CoverageFormatter
328
386
  REPORT_DIR_ENV: String
329
387
  REPORT_FILE_NAME: String
@@ -344,25 +402,57 @@ module Henitai
344
402
  end
345
403
 
346
404
  class SamplingStrategy
405
+ DEFAULT_SEED: Integer
406
+
347
407
  def initialize: () -> void
348
- def sample: (Array[Mutant], ratio: Float, ?strategy: Symbol) -> Array[Mutant]
408
+ def sample: (Array[Mutant], ratio: Float, ?strategy: Symbol, ?seed: Integer) -> Array[Mutant]
349
409
  end
350
410
 
351
411
  class TimeoutCalibrator
352
412
  FLOOR_SECONDS: Float
353
413
 
354
- def initialize: (timing_source: untyped, multiplier: untyped) -> void
414
+ def initialize: (timing_source: untyped, multiplier: untyped, ?boot_seconds: ^() -> Float, ?include_boot: bool) -> void
355
415
  def timeout_for: (untyped) -> Float?
356
416
 
357
417
  private
358
418
 
419
+ def boot_component: () -> Float
359
420
  def durations: () -> Hash[String, untyped]
360
421
  def normalize: (untyped) -> String
361
422
  end
362
423
 
424
+ class TimeoutCeiling
425
+ def initialize: (ceiling: Float?, warner: untyped) -> void
426
+ def cap: (Float, Float) -> Float
427
+
428
+ private
429
+
430
+ def warn_baseline_exceeds_ceiling: (Float) -> void
431
+ end
432
+
433
+ class SuiteBootClock
434
+ STARTED_AT_ENV: String
435
+
436
+ def self.from_env: (Hash[String, String], ?clock: ^() -> Float) -> SuiteBootClock
437
+ def self.parse_timestamp: (untyped) -> Float?
438
+ def initialize: (started_at: Float?, ?clock: ^() -> Float) -> void
439
+ def mark_first_test_started: () -> void
440
+ def boot_seconds: () -> Float
441
+ def measured?: () -> bool
442
+ end
443
+
444
+ class ProcessWakeup
445
+ def initialize: (?signal_name: String) -> void
446
+ def install: () -> self
447
+ def watch: () { () -> Array[untyped] } -> void
448
+ def wait: (Float?) -> void
449
+ def drain: () -> void
450
+ def close: () -> void
451
+ end
452
+
363
453
  class TestPrioritizer
364
454
  def initialize: (?timing_source: untyped?) -> void
365
- def sort: (Array[String], untyped, Hash[untyped, untyped]) -> Array[String]
455
+ def sort: (Array[String], untyped, untyped) -> Array[String]
366
456
 
367
457
  private
368
458
 
@@ -395,7 +485,6 @@ module Henitai
395
485
 
396
486
  def select_tests: (Subject) -> Array[String]
397
487
  def test_files: () -> Array[String]
398
- def run_mutant: (mutant: Mutant, test_files: Array[String], timeout: Float) -> ScenarioExecutionResult
399
488
  def spawn_mutant: (mutant: Mutant, test_files: Array[String]) -> ChildHandle
400
489
  def run_suite: (Array[String], ?timeout: Float) -> ScenarioExecutionResult
401
490
  def per_test_coverage_supported?: () -> bool
@@ -421,7 +510,6 @@ module Henitai
421
510
 
422
511
  module MutantRunSupport
423
512
  def spawn_mutant: (mutant: Mutant, test_files: Array[String]) -> ChildHandle
424
- def run_mutant: (mutant: Mutant, test_files: Array[String], timeout: Float) -> ScenarioExecutionResult
425
513
  def scenario_log_paths: (String) -> Hash[Symbol, String]
426
514
  def build_result: (untyped, Hash[Symbol, String]) -> ScenarioExecutionResult
427
515
  def run_in_child: (mutant: Mutant, test_files: Array[String], log_paths: Hash[Symbol, String]) -> Integer
@@ -432,6 +520,11 @@ module Henitai
432
520
  def run_child_activation_and_tests: (mutant: Mutant, test_files: Array[String], log_paths: Hash[Symbol, String]) -> Integer
433
521
  end
434
522
 
523
+ class CappedLogSink
524
+ def initialize: (untyped, Integer) -> void
525
+ def write: (String) -> void
526
+ end
527
+
435
528
  class ScenarioLogSupport
436
529
  def capture_child_output: (Hash[Symbol, String]) { () -> untyped } -> untyped
437
530
  def with_coverage_dir: (String) { () -> untyped } -> untyped
@@ -465,12 +558,12 @@ module Henitai
465
558
  class ChildHandle
466
559
  attr_accessor pid: Integer?
467
560
  attr_accessor log_paths: Hash[Symbol, String]
561
+ attr_accessor timeout: Float?
468
562
 
469
- def initialize: (pid: Integer?, log_paths: Hash[Symbol, String]) -> void
563
+ def initialize: (pid: Integer?, log_paths: Hash[Symbol, String], ?timeout: Float?) -> void
470
564
  end
471
565
 
472
566
  class RspecProcessRunner
473
- def run_mutant: (Base, mutant: Mutant, test_files: Array[String], timeout: Float) -> ScenarioExecutionResult
474
567
  def run_suite: (Base, Array[String], timeout: Float) -> ScenarioExecutionResult
475
568
  def spawn_mutant: (Base, mutant: Mutant, test_files: Array[String], log_paths: Hash[Symbol, String]) -> ChildHandle
476
569
  end
@@ -478,6 +571,7 @@ module Henitai
478
571
  class Rspec < Base
479
572
  include MutantRunSupport
480
573
  include RspecChildRunner
574
+ include RspecPreload
481
575
  include RspecTestSelection
482
576
 
483
577
  DEFAULT_SUITE_TIMEOUT: Float
@@ -491,7 +585,8 @@ module Henitai
491
585
 
492
586
  private
493
587
 
494
- def run_tests: (Array[String]) -> Integer
588
+ def outcome_recording_hook: (TestFileOutcomes, (^() -> untyped)?) -> (^() -> untyped)
589
+ def run_tests: (Array[String], TestFileOutcomes) ?{ () -> untyped } -> Integer
495
590
  end
496
591
 
497
592
  module CoverageRuntimeSuppressors
@@ -515,14 +610,13 @@ module Henitai
515
610
 
516
611
  def test_files: () -> Array[String]
517
612
  def per_test_coverage_supported?: () -> bool
518
- def run_mutant: (mutant: Mutant, test_files: Array[String], timeout: Float) -> ScenarioExecutionResult
519
613
  def spawn_mutant: (mutant: Mutant, test_files: Array[String]) -> ChildHandle
520
614
  def run_in_child: (mutant: Mutant, test_files: Array[String], log_paths: Hash[Symbol, String]) -> Integer
521
615
  def run_suite: (Array[String], ?timeout: Float) -> ScenarioExecutionResult
522
616
 
523
617
  private
524
618
 
525
- def run_tests: (Array[String]) -> Integer
619
+ def run_tests: (Array[String], TestFileOutcomes) ?{ () -> untyped } -> Integer
526
620
  def preload_environment: () -> void
527
621
  def setup_load_path: () -> void
528
622
  def suppress_minitest_autorun!: () -> nil
@@ -541,12 +635,13 @@ module Henitai
541
635
 
542
636
  class GitDiffAnalyzer
543
637
  def changed_files: (from: String, to: String, ?dir: String) -> Array[String]
638
+ def changed_files_since: (String, ?dir: String) -> Array[String]
544
639
  def working_tree_changed_files: (?dir: String) -> Array[String]
545
640
  def head_sha: (?dir: String) -> String?
546
641
  end
547
642
 
548
643
  class MutantGenerator
549
- def generate: (Array[Subject], Array[untyped], ?config: untyped) -> Array[Mutant]
644
+ def generate: (Array[Subject], Array[untyped], ?config: untyped, ?sample: bool) -> Array[Mutant]
550
645
  end
551
646
 
552
647
  module MutantIdentity
@@ -554,11 +649,27 @@ module Henitai
554
649
  def self.legacy_stable_id: (Mutant) -> String
555
650
  end
556
651
 
652
+ class HistoryCheckpointer
653
+ attr_reader committed: Integer
654
+ def initialize: (history_store: untyped, config: untyped, run_id: String, ?version: String, ?clock: untyped, ?warner: untyped) -> void
655
+ def progress: (untyped, **untyped) -> void
656
+ def flush: () -> void
657
+ end
658
+
659
+ class ExecutionProvenance
660
+ UNCAPTURED: untyped
661
+ def self.capture: (Array[String], ?root: String) -> ExecutionProvenance
662
+ def self.stat_of: (String) -> Array[Integer]?
663
+ def initialize: (stats: Hash[String, Array[Integer]?], dependencies: Array[String], root: String) -> void
664
+ def intact?: (Array[String]) -> bool
665
+ end
666
+
557
667
  class MutantHistoryStore
558
668
  attr_reader path: String
559
669
 
560
- def initialize: (path: String, ?per_test_coverage: PerTestCoverage?) -> void
561
- def record: (untyped, version: String, ?recorded_at: Time) -> void
670
+ def initialize: (path: String, ?per_test_coverage: PerTestCoverage?, ?reuse_context: ReuseContext?, ?provenance: untyped) -> void
671
+ def record: (untyped, version: String, ?recorded_at: Time, ?run_id: String?) -> void
672
+ def checkpoint: (Array[untyped], version: String, run_id: String, ?recorded_at: Time) -> Integer
562
673
  def verdict_for: (String) -> Hash[Symbol, untyped]?
563
674
  def killed_verdict_for: (String) -> Hash[Symbol, untyped]?
564
675
  def trend_report: () -> Hash[Symbol, untyped]
@@ -607,6 +718,7 @@ module Henitai
607
718
  def coverage_lines_by_file: (?String) -> Hash[String, Array[Integer]]
608
719
  def test_lines_by_file: (?String) -> Hash[String, Hash[String, Array[Integer]]]
609
720
  def durations_by_test: (?String) -> Hash[String, Float]
721
+ def boot_seconds: (?String) -> Float
610
722
  end
611
723
 
612
724
  class ProcessWorkerRunner
@@ -649,14 +761,15 @@ module Henitai
649
761
  end
650
762
 
651
763
  class IncrementalFilter
652
- def initialize: (history_store: untyped, ?per_test_coverage: PerTestCoverage?, ?dependency_fingerprint: String?) -> void
764
+ def initialize: (history_store: untyped, ?per_test_coverage: PerTestCoverage?, ?reuse_context: ReuseContext?) -> void
653
765
  def apply: (Array[Mutant]) -> Array[Mutant]
654
766
 
655
767
  private
656
768
 
657
769
  def history_store: () -> untyped
658
770
  def per_test_coverage: () -> PerTestCoverage?
659
- def dependency_fingerprint: () -> String?
771
+ def reuse_context: () -> ReuseContext?
772
+ def context_sha: () -> String?
660
773
  def ambiguous_stable_ids: (Array[Mutant]) -> Set[String]
661
774
  def reusable_status: (Mutant) -> Symbol?
662
775
  def killed_reusable?: (Mutant, Hash[Symbol, untyped]) -> bool
@@ -664,15 +777,25 @@ module Henitai
664
777
  def subject_source_unchanged?: (Mutant, Hash[Symbol, untyped]) -> bool
665
778
  end
666
779
 
780
+ class ReuseContext
781
+ def initialize: (config: untyped, ?version: String, ?root: String) -> void
782
+ def fingerprint: () -> String?
783
+
784
+ private
785
+
786
+ def compute: () -> String?
787
+ def components: (String) -> Hash[String, untyped]
788
+ end
789
+
667
790
  module VerdictFingerprint
668
791
  DEPENDENCY_GLOBS: Array[String]
669
792
 
670
793
  def self?.subject_source_hash: (untyped) -> String?
671
- def self?.tests_fingerprint: (untyped) -> String?
672
- def self?.tests_fingerprint_current?: (String?) -> bool
794
+ def self?.tests_fingerprint: (untyped, context_sha: String?) -> String?
795
+ def self?.tests_fingerprint_current?: (String?, context_sha: String?) -> bool
673
796
  def self?.dependency_fingerprint: (?String) -> String?
674
- def self?.survivor_tests_fingerprint: (untyped, dependency_sha: String?) -> String?
675
- def self?.survivor_fingerprint_current?: (String?, live_paths: Array[String], dependency_sha: String?) -> bool
797
+ def self?.survivor_tests_fingerprint: (untyped, context_sha: String?) -> String?
798
+ def self?.survivor_fingerprint_current?: (String?, live_paths: Array[String], context_sha: String?) -> bool
676
799
  def self?.survivor_fingerprint_matches?: (untyped, Array[String], String?) -> bool
677
800
  def self?.combined_content_sha: (untyped) -> String?
678
801
  end
@@ -741,9 +864,13 @@ module Henitai
741
864
  def map: () -> Hash[String, Hash[String, Array[Integer]]]
742
865
  end
743
866
 
867
+ module SignatureLine
868
+ def self.on?: (untyped) -> bool
869
+ end
870
+
744
871
  class PerTestCoverageSelector
745
872
  def initialize: (?coverage_report_reader: CoverageReportReader) -> void
746
- def filter: (Array[String], Mutant, reports_dir: String) -> Array[String]
873
+ def select: (Mutant, reports_dir: String, test_files: ^() -> Array[String], fallback: ^() -> Array[String]) -> Array[String]
747
874
 
748
875
  private
749
876
 
@@ -752,22 +879,19 @@ module Henitai
752
879
  end
753
880
 
754
881
  class ExecutionEngine
882
+ def initialize: (?runtime: untyped, ?wakeup: untyped) -> void
755
883
  def run: (Array[Mutant], untyped, untyped, ?progress_reporter: untyped) -> Array[Mutant]
756
884
 
757
885
  private
758
886
 
759
887
  def execute: (Array[Mutant], untyped, untyped, untyped?) -> Array[Mutant]
760
888
  def with_worker_slot: () { () -> untyped } -> untyped
761
- def parallel_execution?: (untyped, Array[Mutant]) -> bool
762
889
  def worker_count: (untyped) -> Integer
763
- def run_linear: (Array[Mutant], untyped, untyped, untyped?, untyped) -> void
764
- def run_parallel: (Array[Mutant], untyped, untyped, untyped?) -> void
765
- def process_mutant: (Mutant, untyped, untyped, untyped?, ?untyped) -> void
890
+ def run_workers: (Array[Mutant], untyped, untyped, untyped?, untyped) -> untyped
766
891
  def prioritized_tests_for: (Mutant, untyped, untyped) -> Array[String]
767
892
  def test_prioritizer: (untyped) -> TestPrioritizer
768
893
  def timing_source: (untyped) -> untyped
769
894
  def test_history: (untyped) -> Hash[untyped, untyped]
770
- def run_with_flaky_retry: (Mutant, untyped, untyped, Array[String], ?untyped) -> ScenarioExecutionResult
771
895
  def warn_flaky_mutants: (Integer) -> void
772
896
  def with_reports_dir: (untyped) { () -> untyped } -> untyped
773
897
  end
@@ -780,8 +904,6 @@ module Henitai
780
904
 
781
905
  private
782
906
 
783
- def load_target: (Subject) -> untyped
784
- def load_source_file: (Subject) -> void
785
907
  def target_for: (Subject) -> untyped
786
908
  def method_source: (Mutant) -> String
787
909
  def body_source: (Mutant) -> String
@@ -790,11 +912,28 @@ module Henitai
790
912
  def same_node?: (untyped, untyped) -> bool
791
913
  def replace_child: (untyped, untyped, untyped) -> untyped
792
914
  def method_body: (untyped) -> untyped
793
- def source_file_from_ast: (Subject) -> String?
794
915
  def node_location_signature: (untyped) -> Array[untyped]?
795
916
  def compile_safe_unparse: (untyped) -> String
796
917
  end
797
918
 
919
+ class Mutant::LexicalTarget
920
+ class SubjectNotLoadedError < StandardError
921
+ end
922
+
923
+ def self.resolve: (Subject, untyped) -> untyped
924
+ def self.load_target: (Subject) -> untyped
925
+ def resolve: (Subject, untyped) -> untyped
926
+ def load_target: (Subject) -> untyped
927
+
928
+ private
929
+
930
+ def ensure_loaded: (Subject, Array[String]) -> void
931
+ def load_toplevel_source: (Subject) -> untyped
932
+ def load_subject_source: (Subject) -> void
933
+ def load_source_file: (Subject) -> void
934
+ def source_file_from_ast: (Subject) -> String?
935
+ end
936
+
798
937
  class Mutant::ParameterSource
799
938
  SERIALIZER_METHODS: Hash[Symbol, Symbol]
800
939
 
@@ -830,6 +969,7 @@ module Henitai
830
969
  def history_store: () -> MutantHistoryStore?
831
970
  def authoritative?: (untyped) -> bool
832
971
  def canonical_path: () -> String
972
+ def merged_schema_for: (untyped) -> untyped
833
973
  end
834
974
 
835
975
  class Terminal < Base
@@ -991,10 +1131,12 @@ module Henitai
991
1131
  attr_reader survivor_stats: Hash[Symbol, untyped]?
992
1132
  attr_reader session_id: String
993
1133
  attr_reader git_sha: String?
1134
+ attr_reader complete_files: Array[String]
994
1135
  attr_reader since: String?
995
1136
  attr_reader coverage_criteria: Hash[Symbol, bool]
1137
+ attr_reader sampling: Hash[Symbol, untyped]?
996
1138
 
997
- def initialize: (mutants: Array[Mutant], started_at: Time, finished_at: Time, ?thresholds: Hash[Symbol, Integer]?, ?partial_rerun: bool, ?survivor_stats: Hash[Symbol, untyped]?, ?session_id: String, ?git_sha: String?, ?source_provider: ^(String) -> String, ?authoritative: bool, ?since: String?, ?coverage_criteria: Hash[Symbol, bool]?) -> void
1139
+ def initialize: (mutants: Array[Mutant], started_at: Time, finished_at: Time, ?thresholds: Hash[Symbol, Integer]?, ?partial_rerun: bool, ?survivor_stats: Hash[Symbol, untyped]?, ?session_id: String, ?git_sha: String?, ?source_provider: ^(String) -> String, ?authoritative: bool, ?since: String?, ?coverage_criteria: Hash[Symbol, bool]?, ?complete_files: Array[String]?, ?sampling: Hash[Symbol, untyped]?) -> void
998
1140
  def partial_rerun?: () -> bool
999
1141
  def authoritative?: () -> bool
1000
1142
  def killed: () -> Integer
@@ -1017,6 +1159,7 @@ module Henitai
1017
1159
  def base_schema: () -> Hash[Symbol, untyped]
1018
1160
  def unmatched_survivor_ids: () -> Array[String]
1019
1161
  def build_files_section: () -> Hash[Symbol, untyped]
1162
+ def file_provenance: () -> Hash[Symbol, String]
1020
1163
  def mutant_to_schema: (Mutant) -> Hash[Symbol, untyped]
1021
1164
  def coverage_schema: (Mutant) -> Hash[Symbol, untyped]
1022
1165
  def replacement_for: (Mutant) -> String
@@ -1047,17 +1190,6 @@ module Henitai
1047
1190
  def load: () -> Report
1048
1191
  end
1049
1192
 
1050
- class SurvivorTestFilter
1051
- def initialize: (
1052
- coverage_map: Hash[String, Array[String]],
1053
- git_sha: String?,
1054
- ?dirty_source_files: bool,
1055
- ?worktree_changed_files: Array[String],
1056
- ?diff_analyzer: GitDiffAnalyzer
1057
- ) -> void
1058
- def apply: (Array[Mutant]) -> Hash[Symbol, Array[Mutant]]
1059
- end
1060
-
1061
1193
  class SurvivorSelector
1062
1194
  DRIFT_THRESHOLD: Float
1063
1195
 
@@ -1086,8 +1218,14 @@ module Henitai
1086
1218
  def integration: () -> untyped
1087
1219
  def operators: () -> Array[Operator]
1088
1220
  def per_test_coverage: () -> PerTestCoverage
1221
+ def source_selection_coverage: () -> PerTestCoverage
1222
+ def reuse_context: () -> ReuseContext
1223
+ def reuse_filter: () -> IncrementalFilter
1089
1224
  def history_store: () -> untyped
1090
- def progress_reporter: (full_run: bool) -> untyped
1225
+ def capture_provenance: (Array[String]) -> ExecutionProvenance
1226
+ def execution_provenance: () -> untyped
1227
+ def progress_reporter: (full_run: bool, ?history_checkpointer: untyped) -> untyped
1228
+ def history_checkpointer: (run_id: String) -> HistoryCheckpointer?
1091
1229
  def source_provider: () -> ^(String) -> String
1092
1230
  end
1093
1231
 
@@ -1142,8 +1280,15 @@ module Henitai
1142
1280
  def integration: () -> untyped
1143
1281
  def operators: () -> untyped
1144
1282
  def progress_reporter: () -> untyped?
1283
+ def history_checkpointer: () -> HistoryCheckpointer?
1284
+ def run_id: () -> String
1285
+ def save_interrupted_progress: () -> void
1286
+ def flush_progress: () -> void
1145
1287
  def history_store: () -> untyped
1288
+ def full_mutant_set?: () -> bool
1146
1289
  def per_test_coverage: () -> PerTestCoverage
1290
+ def reuse_filter: () -> IncrementalFilter
1291
+ def source_selection_coverage: () -> PerTestCoverage
1147
1292
  def history_store_path: () -> String
1148
1293
  def source_files: () -> Array[String]
1149
1294
  def source_file_selection: () -> SourceFileSelection
@@ -1155,6 +1300,7 @@ module Henitai
1155
1300
  def build_result_object: (Array[Mutant], Time, Time) -> Result
1156
1301
  def pipeline_mutants: () -> Array[Mutant]
1157
1302
  def apply_incremental_filter: (Array[Mutant]) -> Array[Mutant]
1303
+ def capture_provenance: () -> ExecutionProvenance
1158
1304
  def dry_run_result: (Array[Mutant], Time, Time) -> Result
1159
1305
  def source_provider: () -> ^(String) -> String
1160
1306
  def persist_history: (Result, Time) -> void
@@ -1164,9 +1310,11 @@ module Henitai
1164
1310
  def with_reports_dir: () { () -> untyped } -> untyped
1165
1311
  def result_thresholds: () -> Hash[Symbol, Integer]?
1166
1312
  def result_coverage_criteria: () -> Hash[Symbol, bool]?
1313
+ def result_sampling: () -> Hash[Symbol, untyped]?
1167
1314
  def optional_config: (Symbol) -> untyped
1168
1315
  def survivor_rerun?: () -> bool
1169
1316
  def full_run?: () -> bool
1317
+ def complete_files: () -> Array[String]
1170
1318
  def survivor_strategy: () -> SurvivorRerunStrategy
1171
1319
  def safe_head_sha: () -> String?
1172
1320
  end
@@ -1177,27 +1325,26 @@ module Henitai
1177
1325
  def initialize: (survivors_from: String?, config: Configuration, git_diff_analyzer: untyped) -> void
1178
1326
  def active?: () -> bool
1179
1327
  def try_recipe_run: () -> Array[Mutant]?
1180
- def apply_selection: (Array[Mutant]) -> Array[Mutant]
1328
+ def apply_selection: (Array[Mutant], ?reuse_filter: IncrementalFilter?) -> Array[Mutant]
1181
1329
 
1182
1330
  private
1183
1331
 
1184
1332
  def load_survivor_report: () -> SurvivorLoader::Report
1185
- def run_from_recipes: (SurvivorLoader::Report, Array[String]?) -> Array[Mutant]?
1186
- def recipe_fast_path_safe?: (SurvivorLoader::Report, Array[String]?) -> bool
1333
+ def run_from_recipes: (SurvivorLoader::Report) -> Array[Mutant]?
1334
+ def recipe_fast_path_safe?: (SurvivorLoader::Report) -> bool
1187
1335
  def recipe_selector_and_stubs: (Array[String], Hash[String, Hash[String, untyped]]) -> [SurvivorSelector, Array[Mutant]]
1188
1336
  def load_activation_recipes: (Array[String]) -> Hash[String, Hash[String, untyped]]?
1189
1337
  def build_stub_mutant: (String, Hash[String, untyped]) -> Mutant
1190
1338
  def stub_subject_from_recipe: (Hash[String, untyped]) -> Subject
1191
1339
  def recipe_location: (Hash[String, untyped]?) -> Hash[Symbol, untyped]
1192
- def finalize_survivor_split: (SurvivorSelector, Array[Mutant], Hash[Symbol, Array[Mutant]]) -> Array[Mutant]
1340
+ def finalize_selection: (SurvivorSelector, Array[Mutant]) -> Array[Mutant]
1193
1341
  def dirty_worktree_changed_files: () -> Array[String]?
1194
1342
  def dirty_source_files?: (Array[String]?, ?git_sha: String?) -> bool
1195
1343
  def committed_changed_files: (String?) -> Array[String]
1196
1344
  def in_include_root?: (String, Array[String]) -> bool
1197
1345
  def normalize_path: (String) -> String
1198
1346
  def warn_survivor_drift: (SurvivorSelector) -> void
1199
- def build_survivor_stats: (SurvivorSelector, Array[Mutant], Hash[Symbol, Array[Mutant]]) -> Hash[Symbol, untyped]
1200
- def test_filter: (SurvivorLoader::Report, ?dirty_source_files: bool) -> SurvivorTestFilter
1347
+ def build_survivor_stats: (SurvivorSelector, Array[Mutant]) -> Hash[Symbol, untyped]
1201
1348
  end
1202
1349
 
1203
1350
  class CoverageBootstrapper
@@ -1211,6 +1358,8 @@ module Henitai
1211
1358
  def coverage_fresh?: (Array[String], Configuration, Integration::Base, Array[String]?) -> bool
1212
1359
  def coverage_report_path: (Configuration) -> String
1213
1360
  def bootstrap_coverage: (Integration::Base, Configuration, ?Array[String]?) -> void
1361
+ def flaky_detection?: (Configuration) -> bool
1362
+ def run_flaky_baseline: (Integration::Base, Configuration, Array[String]) -> void
1214
1363
  def resolve_test_files: (Integration::Base, Array[String]?, Configuration) -> Array[String]
1215
1364
  def configured_test_excludes: (Configuration) -> Array[String]?
1216
1365
  def source_file_paths: (Array[String]) -> Array[String]
@@ -1237,5 +1386,54 @@ module RSpec
1237
1386
  class Runner
1238
1387
  def self.run: (Array[String]) -> Integer
1239
1388
  end
1389
+
1390
+ end
1391
+ end
1392
+
1393
+ module Henitai
1394
+ class TestFileOutcomes
1395
+ REPORT_FILE_NAME: String
1396
+
1397
+ def self.report_path: (String) -> String
1398
+ def self.default_report_path: () -> String
1399
+ def self.load: (String) -> TestFileOutcomes
1400
+ def initialize: (?on_started: ^(String) -> untyped?) -> void
1401
+ def started: (String) -> void
1402
+ def record: (String, failed: bool) -> void
1403
+ def record_unattributed_failure: () -> void
1404
+ def unattributed_failures?: () -> bool
1405
+ def failed_files: () -> Array[String]
1406
+ def outcomes: () -> Hash[String, String]
1407
+ def write: (String) -> void
1408
+ end
1409
+
1410
+ class FlakyTestRegistry
1411
+ FILE_NAME: String
1412
+
1413
+ def self.from_outcomes: (Hash[String, String], Hash[String, String]) -> FlakyTestRegistry
1414
+ def self.load: (String) -> FlakyTestRegistry
1415
+ def self.for_config: (untyped) -> FlakyTestRegistry
1416
+ def self.for_reports_dir: (String?) -> FlakyTestRegistry
1417
+ def initialize: (Array[String]) -> void
1418
+ def all: () -> Array[String]
1419
+ def flaky?: (String) -> bool
1420
+ def empty?: () -> bool
1421
+ def write: (String) -> void
1422
+ end
1423
+
1424
+ class FlakyDetectionBaseline
1425
+ def initialize: (reports_dir: String, ?timeout: Numeric) -> void
1426
+ def run: (integration: untyped, test_files: Array[String]) -> FlakyTestRegistry
1427
+ end
1428
+
1429
+ module BootstrapErrorMessage
1430
+ GENERIC: String
1431
+
1432
+ def self.build: (untyped, ?timeout: Numeric?) -> String
1433
+ end
1434
+
1435
+ class FlakyRetryDecision
1436
+ def initialize: (flaky_tests: FlakyTestRegistry, max_retries: Integer) -> void
1437
+ def retry?: (status: Symbol, killing_tests: Array[String], attempts: Integer) -> bool
1240
1438
  end
1241
1439
  end