branchproof 0.2.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 (48) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +36 -0
  3. data/CODE_OF_CONDUCT.md +10 -0
  4. data/LICENSE.txt +202 -0
  5. data/NOTICE +3 -0
  6. data/README.md +242 -0
  7. data/doc/Branchproof/Analyzer.md +26 -0
  8. data/doc/Branchproof/CLI.md +15 -0
  9. data/doc/Branchproof/Error.md +6 -0
  10. data/doc/Branchproof/Evidence.md +46 -0
  11. data/doc/Branchproof/Instrumenter.md +18 -0
  12. data/doc/Branchproof/Limits.md +21 -0
  13. data/doc/Branchproof/Loader.md +25 -0
  14. data/doc/Branchproof/Minimizer.md +15 -0
  15. data/doc/Branchproof/MinitestAdapter.md +28 -0
  16. data/doc/Branchproof/Project.md +23 -0
  17. data/doc/Branchproof/RailsSupport/Error.md +6 -0
  18. data/doc/Branchproof/RailsSupport.md +32 -0
  19. data/doc/Branchproof/Records.md +38 -0
  20. data/doc/Branchproof/Report.md +26 -0
  21. data/doc/Branchproof/Runtime.md +37 -0
  22. data/doc/Branchproof/Source.md +23 -0
  23. data/doc/Branchproof/Worker.md +45 -0
  24. data/doc/Branchproof.md +33 -0
  25. data/doc/CHANGELOG.md +36 -0
  26. data/doc/README.md +242 -0
  27. data/exe/mcdc +6 -0
  28. data/lib/branchproof/analyzer.rb +454 -0
  29. data/lib/branchproof/cli.rb +266 -0
  30. data/lib/branchproof/evidence.rb +484 -0
  31. data/lib/branchproof/instrumenter.rb +150 -0
  32. data/lib/branchproof/limits.rb +44 -0
  33. data/lib/branchproof/loader.rb +140 -0
  34. data/lib/branchproof/minimizer.rb +198 -0
  35. data/lib/branchproof/minitest_adapter.rb +245 -0
  36. data/lib/branchproof/project.rb +53 -0
  37. data/lib/branchproof/rails_support.rb +74 -0
  38. data/lib/branchproof/records.rb +76 -0
  39. data/lib/branchproof/report.rb +412 -0
  40. data/lib/branchproof/runtime.rb +171 -0
  41. data/lib/branchproof/source.rb +238 -0
  42. data/lib/branchproof/version.rb +5 -0
  43. data/lib/branchproof/worker.rb +145 -0
  44. data/lib/branchproof.rb +24 -0
  45. data/lib/mcdc.rb +3 -0
  46. data/llms.txt +33 -0
  47. data/sig/branchproof.rbs +116 -0
  48. metadata +132 -0
@@ -0,0 +1,15 @@
1
+ # Class Branchproof::Minimizer <a id="class-Branchproof-Minimizer"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Inherits** | Object |
6
+ | **Defined in** | lib/branchproof/minimizer.rb |
7
+
8
+ Computes minimum vector or test covers for proven obligations.
9
+
10
+ ## Public Instance Methods
11
+ ### `call(objective:, decision_ids:)` <a id="method-i-call"></a> <a id="call-instance_method"></a>
12
+ - **@raise** [ArgumentError]
13
+
14
+ ### `initialize(analysis:, evidence:, limits:)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
15
+ - **@return** [Minimizer] a new instance of Minimizer
@@ -0,0 +1,28 @@
1
+ # Class Branchproof::MinitestAdapter <a id="class-Branchproof-MinitestAdapter"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Inherits** | Object |
6
+ | **Defined in** | lib/branchproof/minitest_adapter.rb |
7
+
8
+ Bridges one serial Minitest run to Runtime lifecycle ownership.
9
+
10
+ ## Attributes
11
+ ### `active_adapter` [RW] <a id="attribute-c-active_adapter"></a> <a id="active_adapter-class_method"></a>
12
+ Returns the value of attribute active_adapter.
13
+
14
+ ### `tests` [R] <a id="attribute-i-tests"></a> <a id="tests-instance_method"></a>
15
+ Returns the value of attribute tests.
16
+
17
+ ## Public Instance Methods
18
+ ### `capabilities()` <a id="method-i-capabilities"></a> <a id="capabilities-instance_method"></a>
19
+ Not documented.
20
+
21
+ ### `initialize(runtime:)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
22
+ - **@return** [MinitestAdapter] a new instance of MinitestAdapter
23
+
24
+ ### `run(test_files:, runner_args:, on_complete:, before_load: = nil)` <a id="method-i-run"></a> <a id="run-instance_method"></a>
25
+ Not documented.
26
+
27
+ ### `validate_runner!()` <a id="method-i-validate_runner-21"></a> <a id="validate_runner!-instance_method"></a>
28
+ - **@raise** [ArgumentError]
@@ -0,0 +1,23 @@
1
+ # Class Branchproof::Project <a id="class-Branchproof-Project"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Inherits** | Object |
6
+ | **Defined in** | lib/branchproof/project.rb |
7
+
8
+ Resolves the project policy used by the isolated analysis worker.
9
+
10
+ ## Constants
11
+ ### `MODES` <a id="constant-MODES"></a> <a id="MODES-constant"></a>
12
+ Not documented.
13
+
14
+ ### `RAILS_ENVIRONMENT` <a id="constant-RAILS_ENVIRONMENT"></a> <a id="RAILS_ENVIRONMENT-constant"></a>
15
+ Not documented.
16
+
17
+ ## Public Instance Methods
18
+ ### `initialize(root:, mode: = "auto")` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
19
+ - **@raise** [ArgumentError]
20
+ - **@return** [Project] a new instance of Project
21
+
22
+ ### `to_h()` <a id="method-i-to_h"></a> <a id="to_h-instance_method"></a>
23
+ Not documented.
@@ -0,0 +1,6 @@
1
+ # Class Branchproof::RailsSupport::Error <a id="class-Branchproof-RailsSupport-Error"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Inherits** | StandardError |
6
+ | **Defined in** | lib/branchproof/rails_support.rb |
@@ -0,0 +1,32 @@
1
+ # Module Branchproof::RailsSupport <a id="module-Branchproof-RailsSupport"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Defined in** | lib/branchproof/rails_support.rb |
6
+
7
+ Boots the selected Rails application after Branchproof's load hook is active.
8
+
9
+ ## Public Class Methods
10
+ ### `boot(project:)` <a id="method-c-boot"></a> <a id="boot-class_method"></a>
11
+ Not documented.
12
+
13
+ ### `boot_environment(environment)` <a id="method-c-boot_environment"></a> <a id="boot_environment-class_method"></a>
14
+ Not documented.
15
+
16
+ ### `environment_path(project)` <a id="method-c-environment_path"></a> <a id="environment_path-class_method"></a>
17
+ Not documented.
18
+
19
+ ### `metadata()` <a id="method-c-metadata"></a> <a id="metadata-class_method"></a>
20
+ Not documented.
21
+
22
+ ### `rails_application()` <a id="method-c-rails_application"></a> <a id="rails_application-class_method"></a>
23
+ - **@raise** [Error]
24
+
25
+ ### `reloading_enabled?(config)` <a id="method-c-reloading_enabled-3F"></a> <a id="reloading_enabled?-class_method"></a>
26
+ - **@return** [Boolean]
27
+
28
+ ### `validate_application!()` <a id="method-c-validate_application-21"></a> <a id="validate_application!-class_method"></a>
29
+ - **@raise** [Error]
30
+
31
+ ### `validate_test_environment()` <a id="method-c-validate_test_environment"></a> <a id="validate_test_environment-class_method"></a>
32
+ - **@raise** [Error]
@@ -0,0 +1,38 @@
1
+ # Module Branchproof::Records <a id="module-Branchproof-Records"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Defined in** | lib/branchproof/records.rb |
6
+
7
+ Builds immutable records and stable identifiers for analysis artifacts.
8
+
9
+ ## Public Class Methods
10
+ ### `build(value)` <a id="method-c-build"></a> <a id="build-class_method"></a>
11
+ Not documented.
12
+
13
+ ### `canonical(value)` <a id="method-c-canonical"></a> <a id="canonical-class_method"></a>
14
+ Not documented.
15
+
16
+ ### `condition_id(decision_id, index)` <a id="method-c-condition_id"></a> <a id="condition_id-class_method"></a>
17
+ Not documented.
18
+
19
+ ### `decision_id(source_id:, context:, byte_start:, byte_length:, tree:)` <a id="method-c-decision_id"></a> <a id="decision_id-class_method"></a>
20
+ Not documented.
21
+
22
+ ### `deep_freeze(value)` <a id="method-c-deep_freeze"></a> <a id="deep_freeze-class_method"></a>
23
+ Not documented.
24
+
25
+ ### `diagnostic(code:, message:, severity: = "warning", source_id: = nil, decision_id: = nil, execution_id: = nil, test_id: = nil, details: = {})` <a id="method-c-diagnostic"></a> <a id="diagnostic-class_method"></a>
26
+ Not documented.
27
+
28
+ ### `id(value)` <a id="method-c-id"></a> <a id="id-class_method"></a>
29
+ Not documented.
30
+
31
+ ### `normalize(value)` <a id="method-c-normalize"></a> <a id="normalize-class_method"></a>
32
+ Not documented.
33
+
34
+ ### `normalize_unknown(value)` <a id="method-c-normalize_unknown"></a> <a id="normalize_unknown-class_method"></a>
35
+ Not documented.
36
+
37
+ ### `source_id(relative_path:, digest:, encoding: = "UTF-8")` <a id="method-c-source_id"></a> <a id="source_id-class_method"></a>
38
+ Not documented.
@@ -0,0 +1,26 @@
1
+ # Class Branchproof::Report <a id="class-Branchproof-Report"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Inherits** | Object |
6
+ | **Defined in** | lib/branchproof/report.rb |
7
+
8
+ Renders versioned terminal and JSON analysis reports.
9
+
10
+ ## Constants
11
+ ### `CRITERION_VERSION` <a id="constant-CRITERION_VERSION"></a> <a id="CRITERION_VERSION-constant"></a>
12
+ Not documented.
13
+
14
+ ### `SCHEMA_VERSION` <a id="constant-SCHEMA_VERSION"></a> <a id="SCHEMA_VERSION-constant"></a>
15
+ Not documented.
16
+
17
+ ## Public Instance Methods
18
+ ### `exit_code()` <a id="method-i-exit_code"></a> <a id="exit_code-instance_method"></a>
19
+ Not documented.
20
+
21
+ ### `initialize(inventory:, evidence:, analysis:, minima:, baseline:, diagnostics:, level: = 3)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
22
+ - **@raise** [ArgumentError]
23
+ - **@return** [Report] a new instance of Report
24
+
25
+ ### `write(io:, format:)` <a id="method-i-write"></a> <a id="write-instance_method"></a>
26
+ - **@raise** [ArgumentError]
@@ -0,0 +1,37 @@
1
+ # Module Branchproof::Runtime <a id="module-Branchproof-Runtime"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Defined in** | lib/branchproof/runtime.rb |
6
+
7
+ Process-local execution recorder. It deliberately never coerces or stores
8
+ application values: Ruby's conditional expression is used for truthiness.
9
+ Captures condition evaluations while preserving application values.
10
+
11
+ ## Public Class Methods
12
+ ### `boot(evidence:)` <a id="method-c-boot"></a> <a id="boot-class_method"></a>
13
+ Not documented.
14
+
15
+ ### `condition(decision_id, index, value)` <a id="method-c-condition"></a> <a id="condition-class_method"></a>
16
+ Not documented.
17
+
18
+ ### `context(test_id:, phase:)` <a id="method-c-context"></a> <a id="context-class_method"></a>
19
+ Not documented.
20
+
21
+ ### `diagnostics()` <a id="method-c-diagnostics"></a> <a id="diagnostics-class_method"></a>
22
+ Not documented.
23
+
24
+ ### `enter(decision_id)` <a id="method-c-enter"></a> <a id="enter-class_method"></a>
25
+ Not documented.
26
+
27
+ ### `finish(decision_id, value)` <a id="method-c-finish"></a> <a id="finish-class_method"></a>
28
+ Not documented.
29
+
30
+ ### `leave(decision_id)` <a id="method-c-leave"></a> <a id="leave-class_method"></a>
31
+ Not documented.
32
+
33
+ ### `register_test(test:)` <a id="method-c-register_test"></a> <a id="register_test-class_method"></a>
34
+ Not documented.
35
+
36
+ ### `snapshot()` <a id="method-c-snapshot"></a> <a id="snapshot-class_method"></a>
37
+ Not documented.
@@ -0,0 +1,23 @@
1
+ # Class Branchproof::Source <a id="class-Branchproof-Source"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Inherits** | Object |
6
+ | **Defined in** | lib/branchproof/source.rb |
7
+
8
+ Inventories supported condition and decision occurrences from Ruby files.
9
+
10
+ ## Attributes
11
+ ### `limits` [R] <a id="attribute-i-limits"></a> <a id="limits-instance_method"></a>
12
+ Returns the value of attribute limits.
13
+
14
+ ### `root` [R] <a id="attribute-i-root"></a> <a id="root-instance_method"></a>
15
+ Returns the value of attribute root.
16
+
17
+ ## Public Instance Methods
18
+ ### `initialize(root:, limits:)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
19
+ - **@raise** [ArgumentError]
20
+ - **@return** [Source] a new instance of Source
21
+
22
+ ### `inventory(paths:)` <a id="method-i-inventory"></a> <a id="inventory-instance_method"></a>
23
+ - **@raise** [ArgumentError]
@@ -0,0 +1,45 @@
1
+ # Module Branchproof::Worker <a id="module-Branchproof-Worker"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Defined in** | lib/branchproof/worker.rb |
6
+
7
+ Runs one isolated Minitest worker and atomically exports its result.
8
+
9
+ ## Public Class Methods
10
+ ### `boot_project(project)` <a id="method-c-boot_project"></a> <a id="boot_project-class_method"></a>
11
+ Not documented.
12
+
13
+ ### `child_process(config_path)` <a id="method-c-child_process"></a> <a id="child_process-class_method"></a>
14
+ Not documented.
15
+
16
+ ### `completion_result(baseline:, project:, rails_metadata:, evidence:, tests:, diagnostics:)` <a id="method-c-completion_result"></a> <a id="completion_result-class_method"></a>
17
+ This result boundary intentionally carries the complete worker payload.
18
+ rubocop:disable-next Metrics/ParameterLists
19
+
20
+ ### `incomplete_evidence(evidence, diagnostics)` <a id="method-c-incomplete_evidence"></a> <a id="incomplete_evidence-class_method"></a>
21
+ Not documented.
22
+
23
+ ### `legacy_project()` <a id="method-c-legacy_project"></a> <a id="legacy_project-class_method"></a>
24
+ Not documented.
25
+
26
+ ### `normalize(value)` <a id="method-c-normalize"></a> <a id="normalize-class_method"></a>
27
+ Not documented.
28
+
29
+ ### `prepend_load_paths(project)` <a id="method-c-prepend_load_paths"></a> <a id="prepend_load_paths-class_method"></a>
30
+ Not documented.
31
+
32
+ ### `project_metadata(project, rails_metadata)` <a id="method-c-project_metadata"></a> <a id="project_metadata-class_method"></a>
33
+ Not documented.
34
+
35
+ ### `project_metadata_for(payload)` <a id="method-c-project_metadata_for"></a> <a id="project_metadata_for-class_method"></a>
36
+ Not documented.
37
+
38
+ ### `symbolize(value)` <a id="method-c-symbolize"></a> <a id="symbolize-class_method"></a>
39
+ Not documented.
40
+
41
+ ### `write_completion(payload, result)` <a id="method-c-write_completion"></a> <a id="write_completion-class_method"></a>
42
+ Not documented.
43
+
44
+ ### `write_failure(payload, code, details)` <a id="method-c-write_failure"></a> <a id="write_failure-class_method"></a>
45
+ Not documented.
@@ -0,0 +1,33 @@
1
+ # Module Branchproof <a id="module-Branchproof"></a>
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | **Defined in** | lib/branchproof.rb, lib/branchproof/cli.rb, lib/branchproof/limits.rb, lib/branchproof/loader.rb, lib/branchproof/report.rb, lib/branchproof/source.rb, lib/branchproof/worker.rb, lib/branchproof/project.rb, lib/branchproof/records.rb, lib/branchproof/runtime.rb, lib/branchproof/version.rb, lib/branchproof/analyzer.rb, lib/branchproof/evidence.rb, lib/branchproof/minimizer.rb, lib/branchproof/instrumenter.rb, lib/branchproof/rails_support.rb, lib/branchproof/minitest_adapter.rb |
6
+
7
+ Public namespace for source inventory and one-run MC/DC reporting.
8
+
9
+ ## Constants
10
+ ### `VERSION` <a id="constant-VERSION"></a> <a id="VERSION-constant"></a>
11
+ Not documented.
12
+
13
+ # Documentation
14
+
15
+ - [Branchproof/Analyzer.md](Branchproof/Analyzer.md)
16
+ - [Branchproof/CLI.md](Branchproof/CLI.md)
17
+ - [Branchproof/Error.md](Branchproof/Error.md)
18
+ - [Branchproof/Evidence.md](Branchproof/Evidence.md)
19
+ - [Branchproof/Instrumenter.md](Branchproof/Instrumenter.md)
20
+ - [Branchproof/Limits.md](Branchproof/Limits.md)
21
+ - [Branchproof/Loader.md](Branchproof/Loader.md)
22
+ - [Branchproof/Minimizer.md](Branchproof/Minimizer.md)
23
+ - [Branchproof/MinitestAdapter.md](Branchproof/MinitestAdapter.md)
24
+ - [Branchproof/Project.md](Branchproof/Project.md)
25
+ - [Branchproof/RailsSupport/Error.md](Branchproof/RailsSupport/Error.md)
26
+ - [Branchproof/RailsSupport.md](Branchproof/RailsSupport.md)
27
+ - [Branchproof/Records.md](Branchproof/Records.md)
28
+ - [Branchproof/Report.md](Branchproof/Report.md)
29
+ - [Branchproof/Runtime.md](Branchproof/Runtime.md)
30
+ - [Branchproof/Source.md](Branchproof/Source.md)
31
+ - [Branchproof/Worker.md](Branchproof/Worker.md)
32
+ - [CHANGELOG.md](CHANGELOG.md)
33
+ - [README.md](README.md)
data/doc/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.2.0] - 2026-09-09
4
+
5
+ - Prepared the initial public-release candidate.
6
+ - Embedded evidence snapshots now report the package version used to produce them.
7
+
8
+ - Added the `mcdc analyze` command for one serial Minitest run.
9
+ - Added Levels 1–3 reports for observations, supporting sets, and MC/DC
10
+ independence evidence in terminal and JSON formats.
11
+ - Added bounded analysis limits and explicit diagnostics for unsupported or
12
+ incomplete evidence.
13
+ - Added automatic and explicit Ruby and Rails project selection for
14
+ `mcdc analyze`.
15
+ - Added deterministic Minitest discovery for both `*_test.rb` and `test_*.rb`
16
+ files.
17
+ - Added isolated Rails test boot with serial, test-environment defaults and
18
+ Rails project metadata in reports.
19
+ - Added support documentation for plain Ruby and Rails projects, including
20
+ the tested Rails 8.1 integration boundary.
21
+ - Added support for ordinary Ruby ternary (`condition ? left : right`)
22
+ predicates, including existing `&&`/`||` condition trees and predicate
23
+ outcome semantics independent of the selected branch value.
24
+ - Improved terminal reports with readable decision and condition labels,
25
+ test names, compact collision-safe IDs, witness and constraint details, and
26
+ named supporting-test sets while preserving the full JSON report.
27
+ - Fixed nested predicate selection so executed ternary decisions are recorded
28
+ across all nested levels without instrumenting unchosen branches.
29
+ - Changed the project license to Apache-2.0; packaged `LICENSE.txt` and
30
+ `NOTICE`.
31
+ - Renamed the gem and public namespace to `branchproof` and `Branchproof`;
32
+ retained `mcdc` and `MCDC` as compatibility surfaces.
33
+
34
+ ## [0.1.0] - 2026-09-09 (unpublished internal milestone)
35
+
36
+ - Initial analytical core and Minitest instrumentation milestone.
data/doc/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # Branchproof
2
+
3
+ Branchproof measures modified condition/decision coverage (MC/DC) from one
4
+ serial Minitest run. It inventories supported `if`, `unless`, `elsif`,
5
+ modifier, and ordinary ternary (`?:`) decisions, records observed vectors,
6
+ and reports independence evidence, missing counterpart constraints, and
7
+ smaller supporting test sets.
8
+
9
+ The gem is named `branchproof`; its command and compatibility namespace are
10
+ `mcdc` and `MCDC`.
11
+
12
+ ## Installation
13
+
14
+ ```sh
15
+ gem install branchproof
16
+ ```
17
+
18
+ Or add it to a bundle:
19
+
20
+ ```sh
21
+ bundle add branchproof
22
+ ```
23
+
24
+ Branchproof targets CRuby 3.3 and 3.4, Minitest 5.x, and Prism 1.x. The
25
+ published core runtime matrix is the CI matrix. Rails support is optional and
26
+ has been locally checked against Rails 8.1.3.1 on CRuby 3.4.5; Rails is
27
+ supplied by the application and is not a runtime dependency of this gem.
28
+ Unsupported syntax and incomplete observations remain visible in the report
29
+ instead of being counted as coverage.
30
+
31
+ ## Analyze a test run
32
+
33
+ Run `mcdc analyze` with the source files or globs to inspect, followed by
34
+ options. A second `--` separates Branchproof options from arguments passed to
35
+ Minitest unchanged:
36
+
37
+ ```sh
38
+ mcdc analyze 'lib/**/*.rb' --test 'test/**/*_test.rb' \
39
+ --level 3 \
40
+ --format terminal \
41
+ --output tmp/branchproof.txt \
42
+ --limits branchproof-limits.json \
43
+ -- --seed 1234
44
+ ```
45
+
46
+ For a plain Ruby application, select the project policy explicitly when
47
+ running from the application root:
48
+
49
+ ```sh
50
+ bundle exec mcdc analyze 'lib/**/*.rb' --project ruby --test 'test/**/*_test.rb'
51
+ ```
52
+
53
+ For a Rails application, run the same command from the application root so
54
+ the application's bundle and Rails version remain in effect:
55
+
56
+ ```sh
57
+ bundle exec mcdc analyze 'app/**/*.rb' --project rails --test 'test/**/*_test.rb'
58
+ ```
59
+
60
+ For a project rooted at the current directory, `--project auto` is the
61
+ default. It selects Rails only when both `config/application.rb` and
62
+ `config/environment.rb` exist; otherwise it selects a plain Ruby project.
63
+ Use `--project ruby` or `--project rails` to override detection. An explicit
64
+ Rails project without both boot files is a usage error.
65
+
66
+ Project defaults discover the sorted, de-duplicated union of
67
+ `test/**/*_test.rb` and `test/**/test_*.rb`. Helper, support, and fixture files
68
+ are excluded from that default set. `--test` remains authoritative when test
69
+ files are selected explicitly. The worker prepends the project's `lib` and
70
+ `test` directories to its child load path, so application `require` calls
71
+ resolve without changing the parent process.
72
+
73
+ Rails analysis boots `config/environment.rb` and `rails/test_help` inside the
74
+ isolated worker after Branchproof's loader and Minitest hooks are installed. The
75
+ child receives `RAILS_ENV=test`, `RACK_ENV=test`, `PARALLEL_WORKERS=1`,
76
+ `DISABLE_BOOTSNAP=1`, and `DISABLE_SPRING=1`; the invoking process environment
77
+ is unchanged. The Rails metadata in the report identifies the selected
78
+ project and Rails version.
79
+
80
+ `--output` writes the report through an atomic replacement. Without it, the
81
+ report is written to standard output. `--format` accepts `terminal` (the
82
+ default) or `json`. JSON includes source identities, criterion and schema
83
+ versions, baseline status, diagnostics, completeness, observations, and
84
+ analysis fields.
85
+
86
+ The terminal format is a compact reading view of the same report. It keeps
87
+ JSON's full stable identifiers and schema unchanged, while shortening IDs to
88
+ eight-character prefixes (extending a prefix when two IDs collide) and
89
+ displaying known Minitest owners as `ClassName#test_method`. When test
90
+ metadata is unavailable, the owner falls back to its short ID. Level 3 adds
91
+ the witness pair or missing counterpart constraints beside each condition;
92
+ Level 2 and Level 3 also list named supporting tests. Repeated supporting-set
93
+ rows are collapsed in terminal output only.
94
+
95
+ For example, running the contents of the small `decision.rb` /
96
+ `test_decision_test.rb` fixture from a project `lib/` and `test/` directory
97
+ with the terminal format produces a summary like this:
98
+
99
+ ```text
100
+ Branchproof 0.2.0
101
+ Tests: PASSED (3 tests, 0 failed, 0 skipped)
102
+ MC/DC: 100.0% (2/2 conditions proven)
103
+ Analysis: COMPLETE
104
+ Decisions: 1 supported, 0 excluded, 0 unexecuted (1 discovered)
105
+ Observations: 3 completed, 0 aborted, 0 unattributed
106
+ Values: T=true, F=false, -=short-circuited
107
+ Scope: supported decisions and conditions
108
+
109
+ Decision dde7aede lib/decision.rb:7
110
+ Decision: left && right
111
+ Status: SUPPORTED
112
+ Condition 0: left
113
+ PROVEN (witness 484eab21 + 8908881e)
114
+ Condition 1: right
115
+ PROVEN (witness e5ec8058 + 8908881e)
116
+ Vector e5ec8058 [TF] => F owners=CliFixtureTest#test_true_false_vector
117
+ Vector 8908881e [TT] => T owners=CliFixtureTest#test_true_true_vector
118
+ Vector 484eab21 [F-] => F owners=CliFixtureTest#test_false_true_vector
119
+
120
+ Supporting sets:
121
+ Vectors (EXACT_MINIMUM, decisions: [dde7aede]): 484eab21, 8908881e, e5ec8058
122
+ Tests (EXACT_MINIMUM, decisions: [dde7aede]): CliFixtureTest#test_true_true_vector, CliFixtureTest#test_false_true_vector, CliFixtureTest#test_true_false_vector
123
+ Additional tests outside this MC/DC evidence set may improve coverage.
124
+ ```
125
+
126
+ The test execution still runs once for the selected level. Use `--format
127
+ json` when a consumer needs the complete identifiers and versioned schema.
128
+
129
+ The levels select how much of the one-run result is displayed:
130
+
131
+ * Level 1 reports observed vectors grouped by their raw decision outcomes.
132
+ * Level 2 includes the smallest supporting sets found for vectors and tests.
133
+ * Level 3 (the default) includes condition independence witnesses and
134
+ counterpart constraints, as well as the Level 1 and 2 evidence.
135
+
136
+ Level 2 and Level 3 compute from the same captured run. They do not rerun the
137
+ test suite. A failed, unsupported, or incomplete run is reported with its
138
+ status and diagnostics and cannot become a successful coverage result by
139
+ changing the display level.
140
+
141
+ ### Supported conditional forms
142
+
143
+ Ordinary Ruby ternaries use the same predicate instrumentation and `&&`/`||`
144
+ condition trees as supported `if` decisions. For example:
145
+
146
+ ```ruby
147
+ value = ready ? false : true
148
+ ```
149
+
150
+ Branchproof records `ready` as the ternary predicate. The decision outcome is
151
+ therefore the truth value of `ready`, even though the selected branch returns
152
+ `false` or `true`; branch selection, returned values, object identity, and
153
+ evaluation order are unchanged. Ternaries nested inside other predicates are
154
+ also inventoried at their own level, including all executed nested levels.
155
+ Expanding the supported syntax increases the eligible-condition denominator,
156
+ so percentages should be compared with that changed scope in mind.
157
+
158
+ The existing predicate exclusions and analysis limits still apply. Keyword
159
+ `and`/`or` expressions, contextual syntax, unsafe or ambiguous predicates,
160
+ and limit overflows remain diagnostics rather than eligible coverage.
161
+
162
+ ### Limits
163
+
164
+ `--limits` accepts a JSON object containing positive integer overrides. The
165
+ available keys are `conditions_per_decision`, `vectors_per_decision`,
166
+ `owner_associations_per_run`, `tests_per_run`, `exact_candidates`,
167
+ `exact_search_nodes`, and `constraint_search_states`.
168
+
169
+ ```json
170
+ {
171
+ "vectors_per_decision": 4096,
172
+ "exact_search_nodes": 50000
173
+ }
174
+ ```
175
+
176
+ Unknown keys and non-positive values are usage errors. When a limit is
177
+ reached, the report says that evidence or analysis is incomplete; it does not
178
+ claim a complete result from truncated data.
179
+
180
+ ### Runner arguments
181
+
182
+ Everything after the argument separator is passed as individual arguments to
183
+ the serial Minitest runner. This is useful for seeds and name filters:
184
+
185
+ ```sh
186
+ mcdc analyze 'lib/**/*.rb' --level 1 -- --seed 9001 -n /checkout/
187
+ ```
188
+
189
+ The 0.2 release supports serial Minitest execution in plain Ruby projects and
190
+ Rails applications. Rails lazy and eager loading are supported when the
191
+ application does not enable reloading for the test run. RSpec, parallel or
192
+ forked runners, mutation execution, Rails system/browser tests, custom Rails
193
+ test commands, generated tests, and reloading configurations are outside this
194
+ release and produce diagnostics rather than a passing analysis.
195
+
196
+ ## Library entry points
197
+
198
+ ```ruby
199
+ require "branchproof"
200
+
201
+ Branchproof::Limits.default
202
+ Branchproof::Records.id(name: "stable identity")
203
+ ```
204
+
205
+ `require "mcdc"` and `MCDC` are compatibility aliases for the same public
206
+ namespace. The CLI is the supported way to run a complete analysis;
207
+ `Branchproof::Project` exposes project selection and child-environment policy,
208
+ and `Branchproof::RailsSupport` is the optional Rails boot boundary. The library
209
+ classes expose the source, runtime, evidence, analysis, and report contracts
210
+ for adapters and integrations.
211
+
212
+ ## Development
213
+
214
+ Use an explicit Ruby executable on systems with multiple Rubies. Clearing
215
+ inherited gem paths prevents one Ruby installation from loading another's
216
+ gems:
217
+
218
+ ```sh
219
+ bundle install
220
+ bundle exec rake
221
+ ```
222
+
223
+ To run the real Rails integration locally, install the optional test bundle
224
+ and set its required flag:
225
+
226
+ ```sh
227
+ BRANCHPROOF_RAILS_INTEGRATION=1 bundle install
228
+ BRANCHPROOF_RAILS_INTEGRATION=1 bundle exec ruby -Ilib:test test/test_rails_integration.rb
229
+ ```
230
+
231
+ The flag makes a missing Rails dependency a failure in the integration job;
232
+ the core suite does not require Rails. Bootsnap is disabled for the child
233
+ Rails process so its compilation cache cannot own the load path during an
234
+ analysis.
235
+
236
+ Run the commands with the Ruby executable you intend to validate. The checked
237
+ release environments are CRuby 3.3.6 and 3.4.5. Each runtime
238
+ must provide the declared Minitest 5.x and Prism 1.x dependencies.
239
+
240
+ ## License
241
+
242
+ Branchproof is available under the [Apache License, Version 2.0](LICENSE.txt).
data/exe/mcdc ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
5
+ require "branchproof"
6
+ exit Branchproof::CLI.new(stdout: $stdout, stderr: $stderr).call(ARGV)