branchproof 0.7.0 → 0.9.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +53 -0
- data/README.md +255 -21
- data/doc/Branchproof/Analyzer.md +2 -2
- data/doc/Branchproof/CLI.md +4 -0
- data/doc/Branchproof/ComparisonReport.md +4 -0
- data/doc/Branchproof/Constraints/Solver.md +21 -0
- data/doc/Branchproof/Constraints.md +98 -0
- data/doc/Branchproof/CoverageIndex.md +3 -0
- data/doc/Branchproof/DecisionSyntax.md +6 -4
- data/doc/Branchproof/DecisionTable.md +153 -0
- data/doc/Branchproof/DefaultInstrumentation.md +13 -0
- data/doc/Branchproof/DefaultRuntime.md +11 -0
- data/doc/Branchproof/DefaultSyntax.md +7 -0
- data/doc/Branchproof/ExceptionInstrumentation.md +9 -0
- data/doc/Branchproof/ExceptionRuntime.md +27 -0
- data/doc/Branchproof/ExceptionSyntax.md +9 -0
- data/doc/Branchproof/ExtendedAlternativeRuntime.md +19 -0
- data/doc/Branchproof/FocusedReport.md +5 -2
- data/doc/Branchproof/Instrumenter.md +1 -1
- data/doc/Branchproof/IterationInstrumentation.md +7 -0
- data/doc/Branchproof/IterationRuntime.md +21 -0
- data/doc/Branchproof/IterationSyntax.md +11 -0
- data/doc/Branchproof/Loader.md +0 -4
- data/doc/Branchproof/MinitestAdapter.md +0 -3
- data/doc/Branchproof/Report.md +18 -0
- data/doc/Branchproof/Runtime.md +60 -1
- data/doc/Branchproof/SavedReport.md +15 -0
- data/doc/Branchproof/Source.md +7 -1
- data/doc/Branchproof/ValueInstrumentation.md +7 -0
- data/doc/Branchproof/ValueRuntime.md +26 -0
- data/doc/Branchproof/ValueSyntax.md +26 -0
- data/doc/Branchproof.md +20 -3
- data/doc/CHANGELOG.md +53 -0
- data/doc/README.md +255 -21
- data/lib/branchproof/analyzer.rb +80 -44
- data/lib/branchproof/cli.rb +28 -19
- data/lib/branchproof/comparison.rb +207 -19
- data/lib/branchproof/comparison_report.rb +49 -1
- data/lib/branchproof/constraints.rb +363 -0
- data/lib/branchproof/coverage_index.rb +30 -1
- data/lib/branchproof/decision_syntax.rb +50 -24
- data/lib/branchproof/decision_table.rb +377 -0
- data/lib/branchproof/default_instrumentation.rb +140 -0
- data/lib/branchproof/default_runtime.rb +16 -0
- data/lib/branchproof/default_syntax.rb +94 -0
- data/lib/branchproof/evidence.rb +133 -31
- data/lib/branchproof/exception_instrumentation.rb +96 -0
- data/lib/branchproof/exception_runtime.rb +41 -0
- data/lib/branchproof/exception_syntax.rb +157 -0
- data/lib/branchproof/extended_alternative_runtime.rb +23 -0
- data/lib/branchproof/flow_instrumentation.rb +52 -23
- data/lib/branchproof/focused_report.rb +77 -9
- data/lib/branchproof/instrumenter.rb +93 -37
- data/lib/branchproof/iteration_instrumentation.rb +66 -0
- data/lib/branchproof/iteration_runtime.rb +79 -0
- data/lib/branchproof/iteration_syntax.rb +75 -0
- data/lib/branchproof/limits.rb +4 -1
- data/lib/branchproof/loader.rb +24 -7
- data/lib/branchproof/minimizer.rb +18 -13
- data/lib/branchproof/minitest_adapter.rb +11 -16
- data/lib/branchproof/records.rb +2 -0
- data/lib/branchproof/report.rb +301 -68
- data/lib/branchproof/runtime.rb +32 -30
- data/lib/branchproof/saved_report.rb +200 -14
- data/lib/branchproof/source.rb +140 -71
- data/lib/branchproof/value_instrumentation.rb +35 -0
- data/lib/branchproof/value_runtime.rb +73 -0
- data/lib/branchproof/value_syntax.rb +116 -0
- data/lib/branchproof/version.rb +1 -1
- data/lib/branchproof/worker.rb +1 -4
- data/lib/branchproof.rb +2 -0
- data/llms.txt +20 -3
- data/sig/branchproof.rbs +64 -1
- metadata +32 -1
data/doc/Branchproof.md
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
| | |
|
|
4
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/comparison.rb, lib/branchproof/instrumenter.rb, lib/branchproof/runtime_flow.rb, lib/branchproof/saved_report.rb, lib/branchproof/rails_support.rb, lib/branchproof/coverage_index.rb, lib/branchproof/focused_report.rb, lib/branchproof/decision_syntax.rb, lib/branchproof/minitest_adapter.rb, lib/branchproof/comparison_report.rb, lib/branchproof/flow_instrumentation.rb |
|
|
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/comparison.rb, lib/branchproof/constraints.rb, lib/branchproof/instrumenter.rb, lib/branchproof/runtime_flow.rb, lib/branchproof/saved_report.rb, lib/branchproof/value_syntax.rb, lib/branchproof/rails_support.rb, lib/branchproof/value_runtime.rb, lib/branchproof/coverage_index.rb, lib/branchproof/decision_table.rb, lib/branchproof/default_syntax.rb, lib/branchproof/focused_report.rb, lib/branchproof/decision_syntax.rb, lib/branchproof/default_runtime.rb, lib/branchproof/exception_syntax.rb, lib/branchproof/iteration_syntax.rb, lib/branchproof/minitest_adapter.rb, lib/branchproof/comparison_report.rb, lib/branchproof/exception_runtime.rb, lib/branchproof/iteration_runtime.rb, lib/branchproof/flow_instrumentation.rb, lib/branchproof/value_instrumentation.rb, lib/branchproof/default_instrumentation.rb, lib/branchproof/exception_instrumentation.rb, lib/branchproof/iteration_instrumentation.rb, lib/branchproof/extended_alternative_runtime.rb |
|
|
6
6
|
|
|
7
|
-
Keep
|
|
8
|
-
|
|
7
|
+
Keep source-boundary and parameter-binding rules together for auditing.
|
|
8
|
+
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,
|
|
9
|
+
Metrics/MethodLength, Metrics/ModuleLength, Metrics/PerceivedComplexity
|
|
9
10
|
|
|
10
11
|
## Constants
|
|
11
12
|
### `VERSION` <a id="constant-VERSION"></a> <a id="VERSION-constant"></a>
|
|
@@ -17,13 +18,26 @@ Not documented.
|
|
|
17
18
|
- [Branchproof/CLI.md](Branchproof/CLI.md)
|
|
18
19
|
- [Branchproof/Comparison.md](Branchproof/Comparison.md)
|
|
19
20
|
- [Branchproof/ComparisonReport.md](Branchproof/ComparisonReport.md)
|
|
21
|
+
- [Branchproof/Constraints/Solver.md](Branchproof/Constraints/Solver.md)
|
|
22
|
+
- [Branchproof/Constraints.md](Branchproof/Constraints.md)
|
|
20
23
|
- [Branchproof/CoverageIndex.md](Branchproof/CoverageIndex.md)
|
|
21
24
|
- [Branchproof/DecisionSyntax.md](Branchproof/DecisionSyntax.md)
|
|
25
|
+
- [Branchproof/DecisionTable.md](Branchproof/DecisionTable.md)
|
|
26
|
+
- [Branchproof/DefaultInstrumentation.md](Branchproof/DefaultInstrumentation.md)
|
|
27
|
+
- [Branchproof/DefaultRuntime.md](Branchproof/DefaultRuntime.md)
|
|
28
|
+
- [Branchproof/DefaultSyntax.md](Branchproof/DefaultSyntax.md)
|
|
22
29
|
- [Branchproof/Error.md](Branchproof/Error.md)
|
|
23
30
|
- [Branchproof/Evidence.md](Branchproof/Evidence.md)
|
|
31
|
+
- [Branchproof/ExceptionInstrumentation.md](Branchproof/ExceptionInstrumentation.md)
|
|
32
|
+
- [Branchproof/ExceptionRuntime.md](Branchproof/ExceptionRuntime.md)
|
|
33
|
+
- [Branchproof/ExceptionSyntax.md](Branchproof/ExceptionSyntax.md)
|
|
34
|
+
- [Branchproof/ExtendedAlternativeRuntime.md](Branchproof/ExtendedAlternativeRuntime.md)
|
|
24
35
|
- [Branchproof/FlowInstrumentation.md](Branchproof/FlowInstrumentation.md)
|
|
25
36
|
- [Branchproof/FocusedReport.md](Branchproof/FocusedReport.md)
|
|
26
37
|
- [Branchproof/Instrumenter.md](Branchproof/Instrumenter.md)
|
|
38
|
+
- [Branchproof/IterationInstrumentation.md](Branchproof/IterationInstrumentation.md)
|
|
39
|
+
- [Branchproof/IterationRuntime.md](Branchproof/IterationRuntime.md)
|
|
40
|
+
- [Branchproof/IterationSyntax.md](Branchproof/IterationSyntax.md)
|
|
27
41
|
- [Branchproof/Limits.md](Branchproof/Limits.md)
|
|
28
42
|
- [Branchproof/Loader.md](Branchproof/Loader.md)
|
|
29
43
|
- [Branchproof/Minimizer.md](Branchproof/Minimizer.md)
|
|
@@ -37,6 +51,9 @@ Not documented.
|
|
|
37
51
|
- [Branchproof/RuntimeFlow.md](Branchproof/RuntimeFlow.md)
|
|
38
52
|
- [Branchproof/SavedReport.md](Branchproof/SavedReport.md)
|
|
39
53
|
- [Branchproof/Source.md](Branchproof/Source.md)
|
|
54
|
+
- [Branchproof/ValueInstrumentation.md](Branchproof/ValueInstrumentation.md)
|
|
55
|
+
- [Branchproof/ValueRuntime.md](Branchproof/ValueRuntime.md)
|
|
56
|
+
- [Branchproof/ValueSyntax.md](Branchproof/ValueSyntax.md)
|
|
40
57
|
- [Branchproof/Worker.md](Branchproof/Worker.md)
|
|
41
58
|
- [CHANGELOG.md](CHANGELOG.md)
|
|
42
59
|
- [README.md](README.md)
|
data/doc/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.9.0] - 2026-09-18
|
|
4
|
+
|
|
5
|
+
- Measure contextual predicates, guarded pattern selection, dynamic case splat
|
|
6
|
+
groups, required pattern matching, and safe-navigation compound assignment.
|
|
7
|
+
- Add coverage for rescue paths, optional argument binding, standalone
|
|
8
|
+
predicates, value alternatives, iteration, and source-visible callbacks.
|
|
9
|
+
- Preserve Boolean criteria for Boolean decisions and report other choices as
|
|
10
|
+
alternative coverage, including their source locations and supporting tests.
|
|
11
|
+
- Exercise 144 Ruby construct fixtures and 406 native cases across source inventory, native behavior,
|
|
12
|
+
runtime evidence, analysis, reports, saved reports, and CLI integration.
|
|
13
|
+
- Preserve nonlocal control transfers on the right side of logical expressions.
|
|
14
|
+
- Harden default-argument, exception, and iteration instrumentation around
|
|
15
|
+
implicit parameters, nonlocal transfers, nested frames, and deferred callbacks.
|
|
16
|
+
- Remove unreachable integer bitwise alternatives and keep their exclusions out
|
|
17
|
+
of coverage denominators.
|
|
18
|
+
- Cache repeated value evidence while preserving vector counts, test/phase
|
|
19
|
+
attribution, and saved-report coverage semantics.
|
|
20
|
+
|
|
21
|
+
## [0.8.0] - 2026-09-17
|
|
22
|
+
|
|
23
|
+
- Derive a reduced decision table for every supported Boolean decision from its
|
|
24
|
+
`AND`/`OR`/`NOT`/atom structure, preserving Ruby short-circuit semantics with
|
|
25
|
+
an explicit `dont_care` value instead of exhaustive Cartesian expansion.
|
|
26
|
+
- Give every rule a stable identity derived from the decision, its normalized
|
|
27
|
+
condition vector, the expected outcome, and the table schema version, so
|
|
28
|
+
saved reports compare across runs, test order, and Minitest seeds.
|
|
29
|
+
- Overlay the existing run's observations onto the rules, attribute covered
|
|
30
|
+
rules to their Minitest tests, and describe uncovered rules as condition-value
|
|
31
|
+
requirements. No additional test execution is performed.
|
|
32
|
+
- Report Decision Table Coverage as its own criterion in the coverage ladder,
|
|
33
|
+
per decision and in aggregate, independently from MC/DC in both directions.
|
|
34
|
+
- Add conservative reachability: `observed`, `unknown`, and
|
|
35
|
+
`statically_impossible` with stable reason codes. Constraint analysis version 2
|
|
36
|
+
requires safe source constraints before excluding rules, keeping arbitrary
|
|
37
|
+
comparison receivers, mutation, and unordered numeric cases unknown.
|
|
38
|
+
- Exclude statically impossible rules from coverage denominators while keeping
|
|
39
|
+
them visible, and let runtime evidence withdraw an impossibility claim with a
|
|
40
|
+
`constraint_model_conflict` diagnostic.
|
|
41
|
+
- Add `--view decision-tables`, which honours `--missing-only` and never lists
|
|
42
|
+
an impossible rule as a missing obligation.
|
|
43
|
+
- Bound table derivation with the new `max_conditions_for_decision_table` and
|
|
44
|
+
`decision_table_rules_per_decision` limits.
|
|
45
|
+
- Persist the table, rule identities, coverage, attribution, and reachability in
|
|
46
|
+
schema `1.3` reports, and distinguish rule-coverage changes from reachability
|
|
47
|
+
changes in offline comparison.
|
|
48
|
+
- Enforce exact rule-limit boundaries and index runtime rule matching rather
|
|
49
|
+
than scanning all observations per rule.
|
|
50
|
+
- Add `--no-reachability` to keep all generated rules as coverage obligations.
|
|
51
|
+
- Align the JSON regression flag with decision-table CLI failures, report
|
|
52
|
+
analysis-version changes, and validate saved rule identities and evidence.
|
|
53
|
+
- Keep uncalculated decision locations and reasons in missing-only reports;
|
|
54
|
+
label `unless` and `until` outcomes as predicate values.
|
|
55
|
+
|
|
3
56
|
## [0.7.0] - 2026-09-10
|
|
4
57
|
|
|
5
58
|
- Discover Boolean loop predicates, subjectless case candidates, standalone
|
data/doc/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# Branchproof
|
|
2
2
|
|
|
3
|
-
Branchproof measures decision, condition,
|
|
4
|
-
coverage
|
|
5
|
-
through Prism, records their runtime paths, and attributes evidence
|
|
6
|
-
Boolean decisions receive the coverage ladder; `case`, pattern
|
|
7
|
-
safe navigation, and conditional assignments receive alternative
|
|
3
|
+
Branchproof measures decision, condition, modified condition/decision (MC/DC),
|
|
4
|
+
and decision-table coverage from one serial Minitest run. It discovers Ruby
|
|
5
|
+
decisions through Prism, records their runtime paths, and attributes evidence
|
|
6
|
+
to tests. Boolean decisions receive the coverage ladder; `case`, pattern
|
|
7
|
+
alternatives, safe navigation, and conditional assignments receive alternative
|
|
8
|
+
coverage.
|
|
8
9
|
|
|
9
10
|
The gem and primary command are named `branchproof`. The `mcdc` command and
|
|
10
11
|
`MCDC` namespace remain compatibility aliases with the same behavior.
|
|
@@ -128,7 +129,7 @@ json` when a consumer needs the complete identifiers and versioned schema.
|
|
|
128
129
|
|
|
129
130
|
### Coverage ladder
|
|
130
131
|
|
|
131
|
-
Each successful `analyze` run calculates
|
|
132
|
+
Each successful `analyze` run calculates five criteria from the same completed
|
|
132
133
|
observations. The report shows their status for each supported decision and
|
|
133
134
|
aggregate counts with explicit denominators:
|
|
134
135
|
|
|
@@ -138,6 +139,7 @@ aggregate counts with explicit denominators:
|
|
|
138
139
|
| Condition | Every atomic condition evaluated both true and false | Two required truth values per supported condition |
|
|
139
140
|
| Condition/Decision | Both Decision and Condition Coverage hold for a decision | Supported decisions |
|
|
140
141
|
| MC/DC | Every condition has an independence witness pair | Supported conditions |
|
|
142
|
+
| Decision Table | Every executable logical rule was exercised | Non-impossible generated rules |
|
|
141
143
|
|
|
142
144
|
For `logged_in? && admin?`, observations `[F-] => F` and `[TT] => T` give:
|
|
143
145
|
|
|
@@ -146,6 +148,7 @@ Decision PASS
|
|
|
146
148
|
Condition FAIL (3/4 values observed)
|
|
147
149
|
Condition/Decision FAIL
|
|
148
150
|
MC/DC FAIL (1/2 conditions proven)
|
|
151
|
+
Decision Table FAIL (2/3 rules covered)
|
|
149
152
|
```
|
|
150
153
|
|
|
151
154
|
The skipped `admin?` in `[F-]` counts as neither true nor false. Conditions
|
|
@@ -155,6 +158,12 @@ for `logged_in?`; `admin?` still needs `[TF] => F`.
|
|
|
155
158
|
|
|
156
159
|
Decision and Condition Coverage are calculated independently from the captured
|
|
157
160
|
evidence. Condition/Decision requires both; MC/DC adds independence evidence.
|
|
161
|
+
Decision Table Coverage is calculated independently of all of them: MC/DC asks
|
|
162
|
+
whether each condition can independently affect the outcome, while Decision
|
|
163
|
+
Table Coverage asks whether each logical rule was exercised. Neither status is
|
|
164
|
+
inferred from the other, so `MC/DC PASS` with `Decision Table FAIL` and the
|
|
165
|
+
reverse are both valid results.
|
|
166
|
+
|
|
158
167
|
Unsupported decisions are excluded from every denominator, while
|
|
159
168
|
unexecuted supported decisions remain in scope. Empty denominators are N/A.
|
|
160
169
|
|
|
@@ -170,6 +179,184 @@ under `analysis.decisions[].coverage`, and condition value evidence under
|
|
|
170
179
|
pairs, counterpart constraints, and raw vectors remain available. Statuses
|
|
171
180
|
distinguish `covered`, `partial`, `unexecuted`, and `unsupported` results.
|
|
172
181
|
|
|
182
|
+
### Decision table coverage
|
|
183
|
+
|
|
184
|
+
For a Boolean decision Branchproof can represent with `AND`, `OR`, `NOT`, and
|
|
185
|
+
atomic conditions, it derives a reduced decision table statically from the
|
|
186
|
+
Boolean structure and then overlays the runtime evidence of the same run. No
|
|
187
|
+
application code is executed while the table is derived, and no extra test run
|
|
188
|
+
is performed while it is overlaid.
|
|
189
|
+
|
|
190
|
+
Rules come directly from the short-circuit evaluation paths of the Ruby expression,
|
|
191
|
+
so a condition the interpreter would
|
|
192
|
+
skip appears as an explicit don't-care (`-`) rather than as two separate rules.
|
|
193
|
+
Exhaustive Boolean expansion is deferred; it is not required to calculate coverage
|
|
194
|
+
and is never performed on the reporting path.
|
|
195
|
+
For `premium? && (admin? || owner?)`:
|
|
196
|
+
|
|
197
|
+
```text
|
|
198
|
+
Decision Table: 3/4 rules covered (75.0%)
|
|
199
|
+
Rule premium? admin? owner? Result Status
|
|
200
|
+
R1 F - - F COVERED
|
|
201
|
+
R2 T T - T COVERED
|
|
202
|
+
R3 T F T T MISSING
|
|
203
|
+
R4 T F F F COVERED
|
|
204
|
+
R1 tests: UserAccessTest#test_free_user
|
|
205
|
+
R2 tests: UserAccessTest#test_admin
|
|
206
|
+
R3
|
|
207
|
+
Need:
|
|
208
|
+
premium? = truthy
|
|
209
|
+
admin? = falsey
|
|
210
|
+
owner? = truthy
|
|
211
|
+
Expected decision:
|
|
212
|
+
true
|
|
213
|
+
Reachability:
|
|
214
|
+
unknown
|
|
215
|
+
R4 tests: UserAccessTest#test_denied
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
A missing rule describes condition values only. It does not claim which
|
|
219
|
+
application inputs would produce them.
|
|
220
|
+
|
|
221
|
+
An observation matches a rule when every required condition value matches and
|
|
222
|
+
the decision outcome matches. Conditions Ruby skipped can only line up with
|
|
223
|
+
don't-care positions; they never satisfy a required true or false. Every rule
|
|
224
|
+
carries a stable identity derived from the decision, its normalized condition
|
|
225
|
+
vector, the expected outcome, and the table schema version — never from a test
|
|
226
|
+
name, an observation order, or the Minitest seed, so saved reports compare
|
|
227
|
+
across runs.
|
|
228
|
+
|
|
229
|
+
Decision tables are derived for `if`, `unless`, `elsif`, ternary, `while`,
|
|
230
|
+
`until`, subjectless `case`/`when`, and supported Boolean pattern guards.
|
|
231
|
+
Multi-way `case`/`when`, `case`/`in` alternatives, safe navigation, conditional
|
|
232
|
+
assignment, and exception handling keep their alternative coverage model and
|
|
233
|
+
produce no Boolean table.
|
|
234
|
+
For `unless` and `until`, the outcome is the predicate value, not whether the
|
|
235
|
+
body executes; the terminal report labels it accordingly.
|
|
236
|
+
|
|
237
|
+
#### Reachability and impossible rules
|
|
238
|
+
|
|
239
|
+
Each rule carries a reachability status: `observed`, `unknown`, or
|
|
240
|
+
`statically_impossible`. Branchproof proves impossibility or leaves
|
|
241
|
+
reachability unknown. It never infers impossibility from a missing test, a
|
|
242
|
+
missing observation, application conventions, Rails validations, database
|
|
243
|
+
constraints, comments, or method names.
|
|
244
|
+
|
|
245
|
+
Constraint analysis version 2 requires evidence that a constraint is safe before
|
|
246
|
+
using it to exclude a rule. A variable name and a numeric literal do not prove
|
|
247
|
+
that the receiver is a number, that its comparison methods use built-in semantics,
|
|
248
|
+
or that its value stays unchanged. Numeric, equality, and nil-check expressions
|
|
249
|
+
are still normalized for inspection, but unproven source constraints remain
|
|
250
|
+
`unknown`. The standalone constraint solver describes its explicit model, not
|
|
251
|
+
arbitrary Ruby objects.
|
|
252
|
+
|
|
253
|
+
Literal truth values can establish impossibility without invoking application
|
|
254
|
+
methods. For `age && false`, the rule requiring the literal `false` to be truthy
|
|
255
|
+
cannot execute:
|
|
256
|
+
|
|
257
|
+
```text
|
|
258
|
+
Decision Table: 2/2 rules covered (100.0%)
|
|
259
|
+
Statically impossible rules excluded: 1
|
|
260
|
+
Rule age false Result Status
|
|
261
|
+
R1 F - F COVERED
|
|
262
|
+
R2 T F F COVERED
|
|
263
|
+
R3 T T T EXCLUDED
|
|
264
|
+
R3 TT => T
|
|
265
|
+
Status:
|
|
266
|
+
EXCLUDED
|
|
267
|
+
Reachability:
|
|
268
|
+
STATICALLY IMPOSSIBLE
|
|
269
|
+
Reason:
|
|
270
|
+
conflicting Boolean literal requirements
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Impossible rules stay visible in the full report but leave the coverage
|
|
274
|
+
denominator. Reason codes are stable: `conflicting_numeric_bounds`,
|
|
275
|
+
`conflicting_equalities`, `equality_outside_numeric_range`, `nil_conflict`, and
|
|
276
|
+
`boolean_literal_conflict`. Human-readable messages may change independently.
|
|
277
|
+
|
|
278
|
+
Runtime evidence is authoritative. If an observation matches a rule the static
|
|
279
|
+
model called impossible, the rule becomes `observed`, the impossibility claim is
|
|
280
|
+
withdrawn, the rule returns to the denominator, and a `constraint_model_conflict`
|
|
281
|
+
diagnostic records the disagreement.
|
|
282
|
+
|
|
283
|
+
For example, `age > 10 && age < 5` stays unknown without a proven domain;
|
|
284
|
+
custom comparison methods can make both comparisons true. Similarly,
|
|
285
|
+
`x > 10 && (x = 0) && x < 5` can execute successfully. `Float::NAN` also prevents
|
|
286
|
+
treating a false comparison as its ordered complement. Runtime evidence can cover
|
|
287
|
+
these rules, but lack of evidence cannot exclude them. Ruby truthiness remains
|
|
288
|
+
distinct from Boolean equality: only `false` and `nil` are falsey.
|
|
289
|
+
|
|
290
|
+
Use `analyze --no-reachability` to disable all static exclusions, including literal
|
|
291
|
+
proofs. Every generated rule then remains an obligation; reports show
|
|
292
|
+
`Reachability: not analyzed`. The mode is persisted with the report and considered
|
|
293
|
+
when comparing analysis contexts. Reading a saved report preserves its original
|
|
294
|
+
analysis; it does not recalculate it under a different mode.
|
|
295
|
+
|
|
296
|
+
#### Decision table views and limits
|
|
297
|
+
|
|
298
|
+
`--view decision-tables` groups the terminal report by decision table, and
|
|
299
|
+
`--missing-only` narrows it to uncovered, non-impossible rules while retaining
|
|
300
|
+
uncalculated decisions with their location and reason. `decision_tables` is an
|
|
301
|
+
accepted compatibility spelling for the view:
|
|
302
|
+
|
|
303
|
+
```sh
|
|
304
|
+
bundle exec branchproof analyze 'lib/**/*.rb' \
|
|
305
|
+
--view decision-tables \
|
|
306
|
+
--missing-only
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Tables grow exponentially with condition count, so
|
|
310
|
+
`max_conditions_for_decision_table` (default 12) and
|
|
311
|
+
`decision_table_rules_per_decision` (default 4096) bound the derivation. A
|
|
312
|
+
decision above either limit reports `Decision Table: NOT CALCULATED` with the
|
|
313
|
+
reason `decision_table_condition_limit_exceeded` or
|
|
314
|
+
`decision_table_rule_limit_exceeded` instead of a partial table.
|
|
315
|
+
|
|
316
|
+
JSON stores the table under `analysis.decisions[].decision_table` with its
|
|
317
|
+
`schema_version`, `constraint_analysis_version`, rules, rule identities, rule
|
|
318
|
+
coverage, test attribution, reachability, and reachability reason. This abbreviated
|
|
319
|
+
example omits counts and evidence bookkeeping fields; full reports also retain
|
|
320
|
+
rule indexes, vector IDs, unattributed counts, and withdrawn-impossibility details:
|
|
321
|
+
|
|
322
|
+
```json
|
|
323
|
+
{
|
|
324
|
+
"decision_table": {
|
|
325
|
+
"status": "calculated",
|
|
326
|
+
"schema_version": 1,
|
|
327
|
+
"constraint_analysis_version": 2,
|
|
328
|
+
"rules": [
|
|
329
|
+
{
|
|
330
|
+
"id": "8f1c...",
|
|
331
|
+
"label": "R1",
|
|
332
|
+
"conditions": ["false", "dont_care", "dont_care"],
|
|
333
|
+
"outcome": false,
|
|
334
|
+
"coverage": "covered",
|
|
335
|
+
"reachability": "observed",
|
|
336
|
+
"tests": ["..."]
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
"id": "3ad0...",
|
|
340
|
+
"label": "R3",
|
|
341
|
+
"conditions": ["true", "false", "true"],
|
|
342
|
+
"outcome": true,
|
|
343
|
+
"coverage": "missing",
|
|
344
|
+
"reachability": "unknown",
|
|
345
|
+
"tests": []
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Aggregate counts live under `analysis.coverage.decision_table` and keep rule
|
|
353
|
+
coverage and fully covered decisions as distinct metrics:
|
|
354
|
+
|
|
355
|
+
```text
|
|
356
|
+
DT (Decision table coverage): 83.9% (47/56 rules)
|
|
357
|
+
Decision tables fully covered: 13/18 decisions
|
|
358
|
+
```
|
|
359
|
+
|
|
173
360
|
### Find missing cases
|
|
174
361
|
|
|
175
362
|
Use `--missing-only` to focus the terminal report on conditions that still
|
|
@@ -231,7 +418,7 @@ analysis even at Level 1. A failed, unsupported, or incomplete run is reported
|
|
|
231
418
|
with its status and diagnostics and cannot become a successful coverage
|
|
232
419
|
result by changing the display level.
|
|
233
420
|
|
|
234
|
-
### Focused condition and
|
|
421
|
+
### Focused condition, test, and decision-table views
|
|
235
422
|
|
|
236
423
|
Use `--view conditions` to group the report by condition. Each condition shows
|
|
237
424
|
its expression, decision, and project-relative source location with the
|
|
@@ -253,6 +440,10 @@ conditions. A test that evaluates both Boolean values is evidence of execution;
|
|
|
253
440
|
it is a proof contributor only when the analyzer's independent witness pair
|
|
254
441
|
uses its observations.
|
|
255
442
|
|
|
443
|
+
Use `--view decision-tables` to group the report by decision table. See
|
|
444
|
+
[Decision table coverage](#decision-table-coverage) for the rule, reachability,
|
|
445
|
+
and attribution detail it renders.
|
|
446
|
+
|
|
256
447
|
`--view` changes terminal grouping and does not change instrumentation or test
|
|
257
448
|
execution. JSON output always contains the complete evidence document, so an
|
|
258
449
|
explicit view cannot be combined with `--format json`. The `mcdc` executable
|
|
@@ -308,7 +499,12 @@ patterns is valid comparison context, and seed differences are disclosed.
|
|
|
308
499
|
|
|
309
500
|
`compare` exits 0 for a complete comparison, including one with coverage
|
|
310
501
|
changes; `--fail-on-regression` exits 1 when a complete comparable run loses
|
|
311
|
-
proof
|
|
502
|
+
MC/DC proof or decision-table rule coverage. The JSON `regression` flag includes
|
|
503
|
+
either kind of loss; `regressions` retains the MC/DC count and
|
|
504
|
+
`decision_table_regressions` supplies the separate rule-loss count. Changes to
|
|
505
|
+
table schemas, constraint-analysis versions, or reachability modes are reported
|
|
506
|
+
as analysis context changes rather than silently treated as unchanged analysis.
|
|
507
|
+
Invalid input or an incomplete comparison exits 2, which takes
|
|
312
508
|
precedence. Reports are explicit snapshots: comparison never creates history,
|
|
313
509
|
promotes a baseline, or overwrites either input.
|
|
314
510
|
|
|
@@ -346,6 +542,13 @@ ID. Repeated equivalent executions aggregate into a vector's `count`, retaining
|
|
|
346
542
|
the supporting tests. Ternary outcomes likewise describe the predicate, not
|
|
347
543
|
the value returned by the chosen branch.
|
|
348
544
|
|
|
545
|
+
Value decisions remain enabled by default. For each decision, evidence caches
|
|
546
|
+
the most recent successful completed trace, keyed by its observations, outcome,
|
|
547
|
+
test, and phase. Consecutive equivalent executions increment vector and phase
|
|
548
|
+
counts without repeating serialization and digest work. When observations,
|
|
549
|
+
test, or phase changes, the execution is recorded normally, so alternating
|
|
550
|
+
traces retain their full evidence and attribution.
|
|
551
|
+
|
|
349
552
|
Other constructs use alternative coverage, separate from MC/DC:
|
|
350
553
|
|
|
351
554
|
| Construct | Kind | Context | Required alternatives |
|
|
@@ -355,6 +558,18 @@ Other constructs use alternative coverage, separate from MC/DC:
|
|
|
355
558
|
| `receiver&.method` | `implicit` | `safe_navigation` | Receiver nil / non-nil |
|
|
356
559
|
| `lhs ||= rhs` | `implicit` | `or_assignment` | RHS skipped / executed |
|
|
357
560
|
| `lhs &&= rhs` | `implicit` | `and_assignment` | RHS skipped / executed |
|
|
561
|
+
| `receiver&.value ||= rhs` / `&&=` | `multiway` | `or_assignment` / `and_assignment` | Receiver nil / RHS skipped / RHS evaluated |
|
|
562
|
+
| `value => pattern` | `pattern` | `required_pattern` | Matched / mismatch |
|
|
563
|
+
| Rescue regions | `exception` | `rescue` | Normal completion / rescue clause / unhandled exception |
|
|
564
|
+
| Optional positional and keyword arguments | `implicit` | `default_argument` | Supplied / default evaluated |
|
|
565
|
+
| Standalone predicate calls | `implicit` | `predicate` | Falsey / truthy result |
|
|
566
|
+
| `<=>` | `multiway` | `comparison` | Negative / zero / positive / nil |
|
|
567
|
+
| `[]` lookup | `multiway` | `lookup` | Truthy / false / nil result |
|
|
568
|
+
| `send`, `public_send`, and `__send__` | `implicit` | `dispatch` | Successful return / exception |
|
|
569
|
+
| Regular-expression match capture | `implicit` | `match_capture` | False / true |
|
|
570
|
+
| Iterator bodies | `implicit` | `iteration` | Empty / entered |
|
|
571
|
+
| Lazy iterator callbacks | `multiway` | `lazy_callback` | Callback entered |
|
|
572
|
+
| `fetch` with a fallback block | `implicit` | `fetch_fallback` | Value present / fallback entered |
|
|
358
573
|
|
|
359
574
|
Each safe-navigation operation in a chain is a distinct decision. Assignment
|
|
360
575
|
instrumentation preserves Ruby's native local, instance, class, global,
|
|
@@ -376,21 +591,39 @@ that fails before choosing a branch is aborted, not counted as a selected
|
|
|
376
591
|
alternative. Selected branches and assignment paths remain observed even when
|
|
377
592
|
their bodies or right-hand sides subsequently raise or return.
|
|
378
593
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
`when`
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
594
|
+
Guarded pattern alternatives measure the selected clause, including guard
|
|
595
|
+
acceptance. The guard also supplies Boolean evidence when Ruby evaluates it.
|
|
596
|
+
A dynamic `when *candidates` is one static candidate group; the report does not
|
|
597
|
+
claim coverage of individual elements in that runtime collection.
|
|
598
|
+
|
|
599
|
+
Flip-flops and implicit regular-expression conditions retain Ruby's conditional
|
|
600
|
+
semantics and contribute one atomic predicate outcome. `defined?` measures its
|
|
601
|
+
result without evaluating or instrumenting the operand. Standalone predicate
|
|
602
|
+
calls record returned truthiness as alternative coverage; they do not claim
|
|
603
|
+
short-circuit conditions or coverage of library internals. Eager bitwise `&`,
|
|
604
|
+
`|`, and `^` are excluded because integer results do not represent Ruby
|
|
605
|
+
truthiness decisions: integer `0` is truthy in Ruby. These expressions add no
|
|
606
|
+
decisions or coverage obligations.
|
|
607
|
+
Dynamic dispatch records completion or exception, and preserves the original
|
|
608
|
+
return value. Lazy callback observations arise only when the callback runs.
|
|
609
|
+
Lookup coverage cannot distinguish an absent key from a stored nil; `fetch`
|
|
610
|
+
fallback coverage measures that separate absence-based choice.
|
|
611
|
+
Optional argument probes use generated local flags and preserve parameter
|
|
612
|
+
signatures, defaults, and existing local bindings. Code that enumerates its own
|
|
613
|
+
local variables can see these instrumentation locals.
|
|
614
|
+
|
|
615
|
+
Unsupported syntax stays visible and outside coverage denominators. Heredocs,
|
|
616
|
+
unsafe predicates, data sections, and limit overflows retain explicit exclusions.
|
|
617
|
+
Ruby-defined custom `!` methods keep their runtime behavior;
|
|
389
618
|
evidence that contradicts Boolean negation is rejected instead of proving
|
|
390
619
|
coverage with an invalid logical model.
|
|
391
620
|
|
|
392
|
-
New reports use schema `1.
|
|
393
|
-
readable.
|
|
621
|
+
New reports use schema `1.3`; saved schema `1.0`, `1.1`, and `1.2` reports
|
|
622
|
+
remain readable. Comparison distinguishes decision-table coverage movement
|
|
623
|
+
(`rule coverage gained`, `rule coverage lost`) from analysis movement
|
|
624
|
+
(`rule reachability changed`), and treats a structurally changed decision as a
|
|
625
|
+
changed decision-table context instead of guessing which old rule a new rule
|
|
626
|
+
corresponds to. Expanded discovery changes coverage denominators, so compare reports
|
|
394
627
|
with their supported syntax scope in mind.
|
|
395
628
|
|
|
396
629
|
### Limits
|
|
@@ -398,7 +631,8 @@ with their supported syntax scope in mind.
|
|
|
398
631
|
`--limits` accepts a JSON object containing positive integer overrides. The
|
|
399
632
|
available keys are `conditions_per_decision`, `vectors_per_decision`,
|
|
400
633
|
`owner_associations_per_run`, `tests_per_run`, `exact_candidates`,
|
|
401
|
-
`exact_search_nodes`,
|
|
634
|
+
`exact_search_nodes`, `constraint_search_states`,
|
|
635
|
+
`max_conditions_for_decision_table`, and `decision_table_rules_per_decision`.
|
|
402
636
|
|
|
403
637
|
```json
|
|
404
638
|
{
|