branchproof 0.7.0 → 0.8.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 +35 -0
- data/README.md +212 -11
- 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/FocusedReport.md +5 -2
- 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 +4 -0
- data/doc/Branchproof/SavedReport.md +15 -0
- data/doc/Branchproof.md +4 -1
- data/doc/CHANGELOG.md +35 -0
- data/doc/README.md +212 -11
- 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 +31 -15
- data/lib/branchproof/decision_table.rb +377 -0
- data/lib/branchproof/evidence.rb +51 -31
- data/lib/branchproof/flow_instrumentation.rb +17 -17
- data/lib/branchproof/focused_report.rb +77 -9
- data/lib/branchproof/instrumenter.rb +45 -34
- data/lib/branchproof/limits.rb +4 -1
- data/lib/branchproof/loader.rb +18 -6
- 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 +22 -30
- data/lib/branchproof/saved_report.rb +200 -14
- data/lib/branchproof/source.rb +90 -48
- data/lib/branchproof/version.rb +1 -1
- data/lib/branchproof/worker.rb +1 -4
- data/lib/branchproof.rb +2 -0
- data/llms.txt +4 -1
- data/sig/branchproof.rbs +47 -1
- metadata +6 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Module Branchproof::DecisionTable <a id="module-Branchproof-DecisionTable"></a>
|
|
2
|
+
|
|
3
|
+
| | |
|
|
4
|
+
| --- | --- |
|
|
5
|
+
| **Defined in** | lib/branchproof/decision_table.rb |
|
|
6
|
+
|
|
7
|
+
Derives the executable logical rules of a supported Boolean decision and
|
|
8
|
+
overlays the runtime evidence that the existing Branchproof run captured.
|
|
9
|
+
|
|
10
|
+
Rules come from the Boolean tree itself rather than from an exhaustive
|
|
11
|
+
Cartesian expansion, so Ruby's short-circuit semantics are preserved: a
|
|
12
|
+
condition the interpreter would skip becomes an explicit `dont_care` value
|
|
13
|
+
instead of two separate rules.
|
|
14
|
+
|
|
15
|
+
Nothing here executes application code, and no additional test run is
|
|
16
|
+
required: overlay consumes the vectors already recorded for the decision.
|
|
17
|
+
|
|
18
|
+
## Constants
|
|
19
|
+
### `CONDITION_VALUES` <a id="constant-CONDITION_VALUES"></a> <a id="CONDITION_VALUES-constant"></a>
|
|
20
|
+
Not documented.
|
|
21
|
+
|
|
22
|
+
### `CONSTRAINT_ANALYSIS_VERSION` <a id="constant-CONSTRAINT_ANALYSIS_VERSION"></a> <a id="CONSTRAINT_ANALYSIS_VERSION-constant"></a>
|
|
23
|
+
Not documented.
|
|
24
|
+
|
|
25
|
+
### `COVERAGE_STATUSES` <a id="constant-COVERAGE_STATUSES"></a> <a id="COVERAGE_STATUSES-constant"></a>
|
|
26
|
+
Not documented.
|
|
27
|
+
|
|
28
|
+
### `COVERAGE_SUMMARY_STATUSES` <a id="constant-COVERAGE_SUMMARY_STATUSES"></a> <a id="COVERAGE_SUMMARY_STATUSES-constant"></a>
|
|
29
|
+
Not documented.
|
|
30
|
+
|
|
31
|
+
### `DEFAULT_MAX_CONDITIONS` <a id="constant-DEFAULT_MAX_CONDITIONS"></a> <a id="DEFAULT_MAX_CONDITIONS-constant"></a>
|
|
32
|
+
Not documented.
|
|
33
|
+
|
|
34
|
+
### `DEFAULT_MAX_RULES` <a id="constant-DEFAULT_MAX_RULES"></a> <a id="DEFAULT_MAX_RULES-constant"></a>
|
|
35
|
+
Not documented.
|
|
36
|
+
|
|
37
|
+
### `DONT_CARE` <a id="constant-DONT_CARE"></a> <a id="DONT_CARE-constant"></a>
|
|
38
|
+
Not documented.
|
|
39
|
+
|
|
40
|
+
### `FALSE_VALUE` <a id="constant-FALSE_VALUE"></a> <a id="FALSE_VALUE-constant"></a>
|
|
41
|
+
Not documented.
|
|
42
|
+
|
|
43
|
+
### `NOT_CALCULATED_REASONS` <a id="constant-NOT_CALCULATED_REASONS"></a> <a id="NOT_CALCULATED_REASONS-constant"></a>
|
|
44
|
+
Not documented.
|
|
45
|
+
|
|
46
|
+
### `REACHABILITY_STATUSES` <a id="constant-REACHABILITY_STATUSES"></a> <a id="REACHABILITY_STATUSES-constant"></a>
|
|
47
|
+
Not documented.
|
|
48
|
+
|
|
49
|
+
### `SCHEMA_VERSION` <a id="constant-SCHEMA_VERSION"></a> <a id="SCHEMA_VERSION-constant"></a>
|
|
50
|
+
Not documented.
|
|
51
|
+
|
|
52
|
+
### `TABLE_STATUSES` <a id="constant-TABLE_STATUSES"></a> <a id="TABLE_STATUSES-constant"></a>
|
|
53
|
+
Not documented.
|
|
54
|
+
|
|
55
|
+
### `TRUE_VALUE` <a id="constant-TRUE_VALUE"></a> <a id="TRUE_VALUE-constant"></a>
|
|
56
|
+
Not documented.
|
|
57
|
+
|
|
58
|
+
### `VALUE_LABELS` <a id="constant-VALUE_LABELS"></a> <a id="VALUE_LABELS-constant"></a>
|
|
59
|
+
Not documented.
|
|
60
|
+
|
|
61
|
+
## Public Class Methods
|
|
62
|
+
### `build(decision:, vectors: = [], limits: = {}, reachability: = true)` <a id="method-c-build"></a> <a id="build-class_method"></a>
|
|
63
|
+
Builds the reduced, runtime-overlaid table for one Boolean decision.
|
|
64
|
+
- **@raise** [ArgumentError]
|
|
65
|
+
|
|
66
|
+
### `classify_vectors(rules, vectors)` <a id="method-c-classify_vectors"></a> <a id="classify_vectors-class_method"></a>
|
|
67
|
+
Generated traces have nil in every skipped condition position. Their
|
|
68
|
+
normalized vector is therefore an exact table key and can be classified
|
|
69
|
+
without scanning every rule. Malformed or hand-built observations retain the
|
|
70
|
+
historical matcher as a bounded compatibility fallback.
|
|
71
|
+
|
|
72
|
+
### `combine(node, type, budget)` <a id="method-c-combine"></a> <a id="combine-class_method"></a>
|
|
73
|
+
Not documented.
|
|
74
|
+
|
|
75
|
+
### `coverage_entry(table)` <a id="method-c-coverage_entry"></a> <a id="coverage_entry-class_method"></a>
|
|
76
|
+
The per-decision row the coverage ladder renders.
|
|
77
|
+
|
|
78
|
+
### `coverage_status(covered, required, generated)` <a id="method-c-coverage_status"></a> <a id="coverage_status-class_method"></a>
|
|
79
|
+
Not documented.
|
|
80
|
+
|
|
81
|
+
### `enumerate(node, prefer, budget)` <a id="method-c-enumerate"></a> <a id="enumerate-class_method"></a>
|
|
82
|
+
Enumerates every short-circuit evaluation path of the Boolean tree.
|
|
83
|
+
|
|
84
|
+
`prefer` orders the paths deterministically: a conjunction lists its
|
|
85
|
+
short-circuiting false path first, a disjunction its true path first, and a
|
|
86
|
+
negation inverts the preference it inherits. Returns nil once the path count
|
|
87
|
+
would exceed `budget`.
|
|
88
|
+
|
|
89
|
+
### `fast_match_positions(vector, by_signature, condition_count)` <a id="method-c-fast_match_positions"></a> <a id="fast_match_positions-class_method"></a>
|
|
90
|
+
Not documented.
|
|
91
|
+
|
|
92
|
+
### `fetch(record, key)` <a id="method-c-fetch"></a> <a id="fetch-class_method"></a>
|
|
93
|
+
Not documented.
|
|
94
|
+
|
|
95
|
+
### `generic_matches(rules, vectors)` <a id="method-c-generic_matches"></a> <a id="generic_matches-class_method"></a>
|
|
96
|
+
Not documented.
|
|
97
|
+
|
|
98
|
+
### `limit(limits, key, fallback)` <a id="method-c-limit"></a> <a id="limit-class_method"></a>
|
|
99
|
+
Not documented.
|
|
100
|
+
|
|
101
|
+
### `matches?(rule, vector)` <a id="method-c-matches-3F"></a> <a id="matches?-class_method"></a>
|
|
102
|
+
A runtime observation matches a rule when every required condition value
|
|
103
|
+
matches and the decision outcome matches. Conditions Ruby skipped may only
|
|
104
|
+
line up with don't-care positions.
|
|
105
|
+
- **@return** [Boolean]
|
|
106
|
+
|
|
107
|
+
### `not_calculated(decision_id, reason)` <a id="method-c-not_calculated"></a> <a id="not_calculated-class_method"></a>
|
|
108
|
+
Not documented.
|
|
109
|
+
|
|
110
|
+
### `overlay(decision_id:, rules:, vectors:, reachability: = true, indexed: = false)` <a id="method-c-overlay"></a> <a id="overlay-class_method"></a>
|
|
111
|
+
Not documented.
|
|
112
|
+
|
|
113
|
+
### `overlay_rule(decision_id, rule, vectors, diagnostics)` <a id="method-c-overlay_rule"></a> <a id="overlay_rule-class_method"></a>
|
|
114
|
+
Public compatibility wrapper: callers historically passed all vectors, so
|
|
115
|
+
retain matcher filtering for direct calls.
|
|
116
|
+
|
|
117
|
+
### `overlay_rule_matches(decision_id, rule, matched, diagnostics)` <a id="method-c-overlay_rule_matches"></a> <a id="overlay_rule_matches-class_method"></a>
|
|
118
|
+
Not documented.
|
|
119
|
+
|
|
120
|
+
### `percentage(covered, required)` <a id="method-c-percentage"></a> <a id="percentage-class_method"></a>
|
|
121
|
+
Not documented.
|
|
122
|
+
|
|
123
|
+
### `representable?(node, condition_count)` <a id="method-c-representable-3F"></a> <a id="representable?-class_method"></a>
|
|
124
|
+
Only AND, OR, NOT, and atoms within the decision's own condition range are
|
|
125
|
+
representable; anything else leaves the table uncalculated rather than
|
|
126
|
+
producing a table that does not describe the decision.
|
|
127
|
+
- **@return** [Boolean]
|
|
128
|
+
|
|
129
|
+
### `rule(decision_id, conditions, path, index, reachability: = true, prepared_constraints: = nil)` <a id="method-c-rule"></a> <a id="rule-class_method"></a>
|
|
130
|
+
rubocop:disable-next Metrics/ParameterLists
|
|
131
|
+
|
|
132
|
+
### `rule_id(decision_id, values, outcome)` <a id="method-c-rule_id"></a> <a id="rule_id-class_method"></a>
|
|
133
|
+
Rule identity depends only on the decision, the normalized condition vector,
|
|
134
|
+
the expected outcome, and the table schema version. It never depends on a test
|
|
135
|
+
name, a runtime observation, or the Minitest seed.
|
|
136
|
+
|
|
137
|
+
### `signature(values, outcome)` <a id="method-c-signature"></a> <a id="signature-class_method"></a>
|
|
138
|
+
Not documented.
|
|
139
|
+
|
|
140
|
+
### `static_reachability(conditions, values, prepared_constraints: = nil)` <a id="method-c-static_reachability"></a> <a id="static_reachability-class_method"></a>
|
|
141
|
+
Conservative static reachability: prove impossibility, or answer unknown.
|
|
142
|
+
|
|
143
|
+
### `summary(decision_id:, rules:, diagnostics:, reachability_analyzed: = true)` <a id="method-c-summary"></a> <a id="summary-class_method"></a>
|
|
144
|
+
Not documented.
|
|
145
|
+
|
|
146
|
+
### `unavailable_reason(decision, limits)` <a id="method-c-unavailable_reason"></a> <a id="unavailable_reason-class_method"></a>
|
|
147
|
+
Names why a decision carries no Boolean table, or nil when it carries one.
|
|
148
|
+
|
|
149
|
+
### `unique_atom_indices?(node, seen = {})` <a id="method-c-unique_atom_indices-3F"></a> <a id="unique_atom_indices?-class_method"></a>
|
|
150
|
+
- **@return** [Boolean]
|
|
151
|
+
|
|
152
|
+
### `unsupported_coverage_entry()` <a id="method-c-unsupported_coverage_entry"></a> <a id="unsupported_coverage_entry-class_method"></a>
|
|
153
|
+
Not documented.
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
Terminal renderings grouped around conditions or tests.
|
|
9
9
|
|
|
10
|
+
## Constants
|
|
11
|
+
### `DECISION_TABLE_LABELS` <a id="constant-DECISION_TABLE_LABELS"></a> <a id="DECISION_TABLE_LABELS-constant"></a>
|
|
12
|
+
Not documented.
|
|
13
|
+
|
|
10
14
|
## Public Instance Methods
|
|
11
|
-
### `initialize(document:, view:, level:, missing_only: = false)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
|
|
12
|
-
- **@raise** [ArgumentError]
|
|
15
|
+
### `initialize(document:, view:, level:, missing_only: = false, coordinator: = nil)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
|
|
13
16
|
- **@return** [FocusedReport] a new instance of FocusedReport
|
|
14
17
|
|
|
15
18
|
### `render()` <a id="method-i-render"></a> <a id="render-instance_method"></a>
|
data/doc/Branchproof/Loader.md
CHANGED
|
@@ -7,10 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
Owns the process-local CRuby compilation hook when the VM exposes it.
|
|
9
9
|
|
|
10
|
-
## Constants
|
|
11
|
-
### `STATUS_KEYS` <a id="constant-STATUS_KEYS"></a> <a id="STATUS_KEYS-constant"></a>
|
|
12
|
-
Not documented.
|
|
13
|
-
|
|
14
10
|
## Public Instance Methods
|
|
15
11
|
### `diagnostics()` <a id="method-i-diagnostics"></a> <a id="diagnostics-instance_method"></a>
|
|
16
12
|
Not documented.
|
|
@@ -15,9 +15,6 @@ Returns the value of attribute active_adapter.
|
|
|
15
15
|
Returns the value of attribute tests.
|
|
16
16
|
|
|
17
17
|
## Public Instance Methods
|
|
18
|
-
### `capabilities()` <a id="method-i-capabilities"></a> <a id="capabilities-instance_method"></a>
|
|
19
|
-
Not documented.
|
|
20
|
-
|
|
21
18
|
### `initialize(runtime:)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
|
|
22
19
|
- **@return** [MinitestAdapter] a new instance of MinitestAdapter
|
|
23
20
|
|
data/doc/Branchproof/Report.md
CHANGED
|
@@ -11,9 +11,18 @@ Renders versioned terminal and JSON analysis reports.
|
|
|
11
11
|
### `CRITERION_VERSION` <a id="constant-CRITERION_VERSION"></a> <a id="CRITERION_VERSION-constant"></a>
|
|
12
12
|
Not documented.
|
|
13
13
|
|
|
14
|
+
### `DECISION_TABLE_LABELS` <a id="constant-DECISION_TABLE_LABELS"></a> <a id="DECISION_TABLE_LABELS-constant"></a>
|
|
15
|
+
Not documented.
|
|
16
|
+
|
|
17
|
+
### `DECISION_TABLE_STATUS_LABELS` <a id="constant-DECISION_TABLE_STATUS_LABELS"></a> <a id="DECISION_TABLE_STATUS_LABELS-constant"></a>
|
|
18
|
+
Not documented.
|
|
19
|
+
|
|
14
20
|
### `SCHEMA_VERSION` <a id="constant-SCHEMA_VERSION"></a> <a id="SCHEMA_VERSION-constant"></a>
|
|
15
21
|
Not documented.
|
|
16
22
|
|
|
23
|
+
### `VIEWS` <a id="constant-VIEWS"></a> <a id="VIEWS-constant"></a>
|
|
24
|
+
Not documented.
|
|
25
|
+
|
|
17
26
|
## Public Class Methods
|
|
18
27
|
### `from_document(document:, level: = nil, view: = :decisions, missing_only: = false)` <a id="method-c-from_document"></a> <a id="from_document-class_method"></a>
|
|
19
28
|
Not documented.
|
|
@@ -32,6 +41,15 @@ Render the shared ladder in every terminal view.
|
|
|
32
41
|
### `coverage_status_label(status)` <a id="method-i-coverage_status_label"></a> <a id="coverage_status_label-instance_method"></a>
|
|
33
42
|
Not documented.
|
|
34
43
|
|
|
44
|
+
### `decision_table_expected_heading(decision)` <a id="method-i-decision_table_expected_heading"></a> <a id="decision_table_expected_heading-instance_method"></a>
|
|
45
|
+
Not documented.
|
|
46
|
+
|
|
47
|
+
### `decision_table_reachability(rule)` <a id="method-i-decision_table_reachability"></a> <a id="decision_table_reachability-instance_method"></a>
|
|
48
|
+
Not documented.
|
|
49
|
+
|
|
50
|
+
### `decision_table_requirement(value)` <a id="method-i-decision_table_requirement"></a> <a id="decision_table_requirement-instance_method"></a>
|
|
51
|
+
Not documented.
|
|
52
|
+
|
|
35
53
|
### `diagnostic_message(diagnostic)` <a id="method-i-diagnostic_message"></a> <a id="diagnostic_message-instance_method"></a>
|
|
36
54
|
Formats source context consistently in live and saved terminal views.
|
|
37
55
|
|
data/doc/Branchproof/Runtime.md
CHANGED
|
@@ -9,6 +9,10 @@ Process-local execution recorder. It deliberately never coerces or stores
|
|
|
9
9
|
application values: Ruby's conditional expression is used for truthiness.
|
|
10
10
|
Captures condition evaluations while preserving application values.
|
|
11
11
|
|
|
12
|
+
## Constants
|
|
13
|
+
### `FRAME_STATE_KEY` <a id="constant-FRAME_STATE_KEY"></a> <a id="FRAME_STATE_KEY-constant"></a>
|
|
14
|
+
Not documented.
|
|
15
|
+
|
|
12
16
|
## Public Class Methods
|
|
13
17
|
### `boot(evidence:)` <a id="method-c-boot"></a> <a id="boot-class_method"></a>
|
|
14
18
|
Not documented.
|
|
@@ -17,12 +17,27 @@ Not documented.
|
|
|
17
17
|
### `DECISION_KINDS` <a id="constant-DECISION_KINDS"></a> <a id="DECISION_KINDS-constant"></a>
|
|
18
18
|
Not documented.
|
|
19
19
|
|
|
20
|
+
### `DECISION_TABLE_STATUSES` <a id="constant-DECISION_TABLE_STATUSES"></a> <a id="DECISION_TABLE_STATUSES-constant"></a>
|
|
21
|
+
Not documented.
|
|
22
|
+
|
|
20
23
|
### `NONBOOLEAN_KINDS` <a id="constant-NONBOOLEAN_KINDS"></a> <a id="NONBOOLEAN_KINDS-constant"></a>
|
|
21
24
|
Not documented.
|
|
22
25
|
|
|
23
26
|
### `REQUIRED_FIELDS` <a id="constant-REQUIRED_FIELDS"></a> <a id="REQUIRED_FIELDS-constant"></a>
|
|
24
27
|
Not documented.
|
|
25
28
|
|
|
29
|
+
### `RULE_CONDITION_VALUES` <a id="constant-RULE_CONDITION_VALUES"></a> <a id="RULE_CONDITION_VALUES-constant"></a>
|
|
30
|
+
Not documented.
|
|
31
|
+
|
|
32
|
+
### `RULE_COVERAGE_STATUSES` <a id="constant-RULE_COVERAGE_STATUSES"></a> <a id="RULE_COVERAGE_STATUSES-constant"></a>
|
|
33
|
+
Not documented.
|
|
34
|
+
|
|
35
|
+
### `RULE_REACHABILITY_STATUSES` <a id="constant-RULE_REACHABILITY_STATUSES"></a> <a id="RULE_REACHABILITY_STATUSES-constant"></a>
|
|
36
|
+
Not documented.
|
|
37
|
+
|
|
38
|
+
### `STRICT_FLOW_SCHEMAS` <a id="constant-STRICT_FLOW_SCHEMAS"></a> <a id="STRICT_FLOW_SCHEMAS-constant"></a>
|
|
39
|
+
Not documented.
|
|
40
|
+
|
|
26
41
|
### `SUPPORTED_SCHEMAS` <a id="constant-SUPPORTED_SCHEMAS"></a> <a id="SUPPORTED_SCHEMAS-constant"></a>
|
|
27
42
|
Not documented.
|
|
28
43
|
|
data/doc/Branchproof.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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/rails_support.rb, lib/branchproof/coverage_index.rb, lib/branchproof/decision_table.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 |
|
|
6
6
|
|
|
7
7
|
Keep each bounded source rewrite together so its evaluation order can be
|
|
8
8
|
audited. rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
@@ -17,8 +17,11 @@ Not documented.
|
|
|
17
17
|
- [Branchproof/CLI.md](Branchproof/CLI.md)
|
|
18
18
|
- [Branchproof/Comparison.md](Branchproof/Comparison.md)
|
|
19
19
|
- [Branchproof/ComparisonReport.md](Branchproof/ComparisonReport.md)
|
|
20
|
+
- [Branchproof/Constraints/Solver.md](Branchproof/Constraints/Solver.md)
|
|
21
|
+
- [Branchproof/Constraints.md](Branchproof/Constraints.md)
|
|
20
22
|
- [Branchproof/CoverageIndex.md](Branchproof/CoverageIndex.md)
|
|
21
23
|
- [Branchproof/DecisionSyntax.md](Branchproof/DecisionSyntax.md)
|
|
24
|
+
- [Branchproof/DecisionTable.md](Branchproof/DecisionTable.md)
|
|
22
25
|
- [Branchproof/Error.md](Branchproof/Error.md)
|
|
23
26
|
- [Branchproof/Evidence.md](Branchproof/Evidence.md)
|
|
24
27
|
- [Branchproof/FlowInstrumentation.md](Branchproof/FlowInstrumentation.md)
|
data/doc/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.8.0] - 2026-09-17
|
|
4
|
+
|
|
5
|
+
- Derive a reduced decision table for every supported Boolean decision from its
|
|
6
|
+
`AND`/`OR`/`NOT`/atom structure, preserving Ruby short-circuit semantics with
|
|
7
|
+
an explicit `dont_care` value instead of exhaustive Cartesian expansion.
|
|
8
|
+
- Give every rule a stable identity derived from the decision, its normalized
|
|
9
|
+
condition vector, the expected outcome, and the table schema version, so
|
|
10
|
+
saved reports compare across runs, test order, and Minitest seeds.
|
|
11
|
+
- Overlay the existing run's observations onto the rules, attribute covered
|
|
12
|
+
rules to their Minitest tests, and describe uncovered rules as condition-value
|
|
13
|
+
requirements. No additional test execution is performed.
|
|
14
|
+
- Report Decision Table Coverage as its own criterion in the coverage ladder,
|
|
15
|
+
per decision and in aggregate, independently from MC/DC in both directions.
|
|
16
|
+
- Add conservative reachability: `observed`, `unknown`, and
|
|
17
|
+
`statically_impossible` with stable reason codes. Constraint analysis version 2
|
|
18
|
+
requires safe source constraints before excluding rules, keeping arbitrary
|
|
19
|
+
comparison receivers, mutation, and unordered numeric cases unknown.
|
|
20
|
+
- Exclude statically impossible rules from coverage denominators while keeping
|
|
21
|
+
them visible, and let runtime evidence withdraw an impossibility claim with a
|
|
22
|
+
`constraint_model_conflict` diagnostic.
|
|
23
|
+
- Add `--view decision-tables`, which honours `--missing-only` and never lists
|
|
24
|
+
an impossible rule as a missing obligation.
|
|
25
|
+
- Bound table derivation with the new `max_conditions_for_decision_table` and
|
|
26
|
+
`decision_table_rules_per_decision` limits.
|
|
27
|
+
- Persist the table, rule identities, coverage, attribution, and reachability in
|
|
28
|
+
schema `1.3` reports, and distinguish rule-coverage changes from reachability
|
|
29
|
+
changes in offline comparison.
|
|
30
|
+
- Enforce exact rule-limit boundaries and index runtime rule matching rather
|
|
31
|
+
than scanning all observations per rule.
|
|
32
|
+
- Add `--no-reachability` to keep all generated rules as coverage obligations.
|
|
33
|
+
- Align the JSON regression flag with decision-table CLI failures, report
|
|
34
|
+
analysis-version changes, and validate saved rule identities and evidence.
|
|
35
|
+
- Keep uncalculated decision locations and reasons in missing-only reports;
|
|
36
|
+
label `unless` and `until` outcomes as predicate values.
|
|
37
|
+
|
|
3
38
|
## [0.7.0] - 2026-09-10
|
|
4
39
|
|
|
5
40
|
- 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
|
|
|
@@ -389,8 +585,12 @@ exclusions. Ruby-defined custom `!` methods keep their runtime behavior;
|
|
|
389
585
|
evidence that contradicts Boolean negation is rejected instead of proving
|
|
390
586
|
coverage with an invalid logical model.
|
|
391
587
|
|
|
392
|
-
New reports use schema `1.
|
|
393
|
-
readable.
|
|
588
|
+
New reports use schema `1.3`; saved schema `1.0`, `1.1`, and `1.2` reports
|
|
589
|
+
remain readable. Comparison distinguishes decision-table coverage movement
|
|
590
|
+
(`rule coverage gained`, `rule coverage lost`) from analysis movement
|
|
591
|
+
(`rule reachability changed`), and treats a structurally changed decision as a
|
|
592
|
+
changed decision-table context instead of guessing which old rule a new rule
|
|
593
|
+
corresponds to. Expanded discovery changes coverage denominators, so compare reports
|
|
394
594
|
with their supported syntax scope in mind.
|
|
395
595
|
|
|
396
596
|
### Limits
|
|
@@ -398,7 +598,8 @@ with their supported syntax scope in mind.
|
|
|
398
598
|
`--limits` accepts a JSON object containing positive integer overrides. The
|
|
399
599
|
available keys are `conditions_per_decision`, `vectors_per_decision`,
|
|
400
600
|
`owner_associations_per_run`, `tests_per_run`, `exact_candidates`,
|
|
401
|
-
`exact_search_nodes`,
|
|
601
|
+
`exact_search_nodes`, `constraint_search_states`,
|
|
602
|
+
`max_conditions_for_decision_table`, and `decision_table_rules_per_decision`.
|
|
402
603
|
|
|
403
604
|
```json
|
|
404
605
|
{
|