butterfly-change-intelligence 0.5.0b1__tar.gz

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 (75) hide show
  1. butterfly_change_intelligence-0.5.0b1/LICENSE +201 -0
  2. butterfly_change_intelligence-0.5.0b1/NOTICE +31 -0
  3. butterfly_change_intelligence-0.5.0b1/PKG-INFO +381 -0
  4. butterfly_change_intelligence-0.5.0b1/README.md +354 -0
  5. butterfly_change_intelligence-0.5.0b1/butterfly/__init__.py +24 -0
  6. butterfly_change_intelligence-0.5.0b1/butterfly/__main__.py +8 -0
  7. butterfly_change_intelligence-0.5.0b1/butterfly/_ts_extractor.cjs +1283 -0
  8. butterfly_change_intelligence-0.5.0b1/butterfly/adapters.py +690 -0
  9. butterfly_change_intelligence-0.5.0b1/butterfly/architecture.py +443 -0
  10. butterfly_change_intelligence-0.5.0b1/butterfly/behavior.py +253 -0
  11. butterfly_change_intelligence-0.5.0b1/butterfly/cli.py +1383 -0
  12. butterfly_change_intelligence-0.5.0b1/butterfly/config.py +217 -0
  13. butterfly_change_intelligence-0.5.0b1/butterfly/contracts.py +780 -0
  14. butterfly_change_intelligence-0.5.0b1/butterfly/discovery.py +442 -0
  15. butterfly_change_intelligence-0.5.0b1/butterfly/engine.py +1190 -0
  16. butterfly_change_intelligence-0.5.0b1/butterfly/errors.py +100 -0
  17. butterfly_change_intelligence-0.5.0b1/butterfly/evidence.py +1044 -0
  18. butterfly_change_intelligence-0.5.0b1/butterfly/evolution.py +224 -0
  19. butterfly_change_intelligence-0.5.0b1/butterfly/fusion.py +399 -0
  20. butterfly_change_intelligence-0.5.0b1/butterfly/gitutil.py +273 -0
  21. butterfly_change_intelligence-0.5.0b1/butterfly/graph.py +280 -0
  22. butterfly_change_intelligence-0.5.0b1/butterfly/impact.py +752 -0
  23. butterfly_change_intelligence-0.5.0b1/butterfly/model.py +517 -0
  24. butterfly_change_intelligence-0.5.0b1/butterfly/policy.py +303 -0
  25. butterfly_change_intelligence-0.5.0b1/butterfly/pyextract.py +1136 -0
  26. butterfly_change_intelligence-0.5.0b1/butterfly/report.py +361 -0
  27. butterfly_change_intelligence-0.5.0b1/butterfly/resolve.py +2226 -0
  28. butterfly_change_intelligence-0.5.0b1/butterfly/semdiff.py +436 -0
  29. butterfly_change_intelligence-0.5.0b1/butterfly/services.py +154 -0
  30. butterfly_change_intelligence-0.5.0b1/butterfly/simulate.py +185 -0
  31. butterfly_change_intelligence-0.5.0b1/butterfly/source.py +240 -0
  32. butterfly_change_intelligence-0.5.0b1/butterfly/store.py +333 -0
  33. butterfly_change_intelligence-0.5.0b1/butterfly/testimpact.py +118 -0
  34. butterfly_change_intelligence-0.5.0b1/butterfly/tsadapter.py +636 -0
  35. butterfly_change_intelligence-0.5.0b1/butterfly/uncertainty.py +646 -0
  36. butterfly_change_intelligence-0.5.0b1/butterfly/util.py +124 -0
  37. butterfly_change_intelligence-0.5.0b1/butterfly/workspace.py +995 -0
  38. butterfly_change_intelligence-0.5.0b1/butterfly_change_intelligence.egg-info/PKG-INFO +381 -0
  39. butterfly_change_intelligence-0.5.0b1/butterfly_change_intelligence.egg-info/SOURCES.txt +73 -0
  40. butterfly_change_intelligence-0.5.0b1/butterfly_change_intelligence.egg-info/dependency_links.txt +1 -0
  41. butterfly_change_intelligence-0.5.0b1/butterfly_change_intelligence.egg-info/entry_points.txt +2 -0
  42. butterfly_change_intelligence-0.5.0b1/butterfly_change_intelligence.egg-info/requires.txt +2 -0
  43. butterfly_change_intelligence-0.5.0b1/butterfly_change_intelligence.egg-info/top_level.txt +1 -0
  44. butterfly_change_intelligence-0.5.0b1/pyproject.toml +65 -0
  45. butterfly_change_intelligence-0.5.0b1/setup.cfg +4 -0
  46. butterfly_change_intelligence-0.5.0b1/tests/test_adapters.py +179 -0
  47. butterfly_change_intelligence-0.5.0b1/tests/test_architecture_evolution.py +284 -0
  48. butterfly_change_intelligence-0.5.0b1/tests/test_behavioral_and_contracts.py +251 -0
  49. butterfly_change_intelligence-0.5.0b1/tests/test_branch_completion.py +872 -0
  50. butterfly_change_intelligence-0.5.0b1/tests/test_ci_simulations.py +80 -0
  51. butterfly_change_intelligence-0.5.0b1/tests/test_cli.py +223 -0
  52. butterfly_change_intelligence-0.5.0b1/tests/test_compare_slice.py +201 -0
  53. butterfly_change_intelligence-0.5.0b1/tests/test_contracts.py +156 -0
  54. butterfly_change_intelligence-0.5.0b1/tests/test_coverage_branches.py +661 -0
  55. butterfly_change_intelligence-0.5.0b1/tests/test_cross_language.py +198 -0
  56. butterfly_change_intelligence-0.5.0b1/tests/test_developer_journeys.py +181 -0
  57. butterfly_change_intelligence-0.5.0b1/tests/test_discovery_git_engine.py +202 -0
  58. butterfly_change_intelligence-0.5.0b1/tests/test_distributed_lab.py +130 -0
  59. butterfly_change_intelligence-0.5.0b1/tests/test_evidence_fusion.py +454 -0
  60. butterfly_change_intelligence-0.5.0b1/tests/test_graph_algorithms.py +279 -0
  61. butterfly_change_intelligence-0.5.0b1/tests/test_impact.py +283 -0
  62. butterfly_change_intelligence-0.5.0b1/tests/test_packaging.py +207 -0
  63. butterfly_change_intelligence-0.5.0b1/tests/test_performance_retention.py +78 -0
  64. butterfly_change_intelligence-0.5.0b1/tests/test_policy.py +110 -0
  65. butterfly_change_intelligence-0.5.0b1/tests/test_polyglot_lab.py +167 -0
  66. butterfly_change_intelligence-0.5.0b1/tests/test_properties.py +167 -0
  67. butterfly_change_intelligence-0.5.0b1/tests/test_resolution.py +632 -0
  68. butterfly_change_intelligence-0.5.0b1/tests/test_scenarios.py +234 -0
  69. butterfly_change_intelligence-0.5.0b1/tests/test_security.py +396 -0
  70. butterfly_change_intelligence-0.5.0b1/tests/test_semdiff.py +188 -0
  71. butterfly_change_intelligence-0.5.0b1/tests/test_simulate.py +147 -0
  72. butterfly_change_intelligence-0.5.0b1/tests/test_store.py +208 -0
  73. butterfly_change_intelligence-0.5.0b1/tests/test_typescript.py +404 -0
  74. butterfly_change_intelligence-0.5.0b1/tests/test_uncertainty_scope.py +232 -0
  75. butterfly_change_intelligence-0.5.0b1/tests/test_workspace.py +306 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,31 @@
1
+ Butterfly
2
+ Copyright 2026 The Butterfly Authors
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ Third-party notices
7
+ -------------------
8
+
9
+ The Butterfly source tree contains no third-party code, and the package declares
10
+ no runtime dependencies. Everything in `butterfly/` and `benchmarks/` is original
11
+ work and uses only the Python standard library.
12
+
13
+ The `skills/` and `.agents/skills/` directories contain agent skill definitions
14
+ copied from public repositories and pinned in `skills-lock.json`:
15
+
16
+ - trailofbits/skills (97 skills)
17
+ - betterlmy/agent-skills (21 skills)
18
+ - obra/superpowers (15 skills)
19
+ - rolandbrecht/agent-skills (4 skills)
20
+ - anthropics/skills (1 skill)
21
+ - apollographql/skills (1 skill)
22
+ - vercel-labs/skills (1 skill)
23
+
24
+ Each skill retains its upstream `SKILL.md` and any licence file it shipped with;
25
+ their licences are those of the upstream projects, not Apache-2.0. They are
26
+ documentation for agent workflows and are not linked into, imported by, or
27
+ distributed with the Butterfly package. See `docs/engineering/SKILL_INVENTORY.md`
28
+ and the `source`/`skills-lock.json` pins for provenance.
29
+
30
+ The fixtures under `fixtures/` are synthetic and original; they contain no
31
+ third-party code. All credentials in fixtures are obviously fake values.
@@ -0,0 +1,381 @@
1
+ Metadata-Version: 2.4
2
+ Name: butterfly-change-intelligence
3
+ Version: 0.5.0b1
4
+ Summary: Local-first software change intelligence: semantic diffs, consequence graphs and evidence.
5
+ Author: Project Butterfly contributors
6
+ License: Apache-2.0
7
+ Project-URL: Documentation, https://github.com/butterfly-tools/butterfly#readme
8
+ Project-URL: Repository, https://github.com/butterfly-tools/butterfly
9
+ Project-URL: Issues, https://github.com/butterfly-tools/butterfly/issues
10
+ Keywords: static-analysis,change-impact-analysis,dependency-graph,developer-tools
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Software Development :: Quality Assurance
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ License-File: NOTICE
25
+ Provides-Extra: dev
26
+ Dynamic: license-file
27
+
28
+ # Butterfly
29
+
30
+ **Small changes. Unseen consequences.**
31
+
32
+ Butterfly is a local-first software change intelligence CLI. It answers, for a
33
+ proposed change:
34
+
35
+ 1. what changed **semantically** (not textually),
36
+ 2. which entities depend on it,
37
+ 3. what direct and indirect consequences could follow,
38
+ 4. what **evidence** supports each consequence,
39
+ 5. what is **unknown**, and why,
40
+ 6. what a reviewer should inspect, test or verify before merging.
41
+
42
+ It is a Python analysis engine with **zero runtime dependencies**, no network
43
+ access, and no code execution. It reports what it cannot see instead of guessing.
44
+
45
+ > [!IMPORTANT]
46
+ > **Scope & Safety Notice (`0.5.0b1` Public Beta)**
47
+ > - **Butterfly identifies *potential* consequences; it does not prove the absence of bugs, regressions, or runtime failures.**
48
+ > - A `PASS` verdict or an empty test list never guarantees a change is safe. Unanalyzed languages, dynamic dispatch, and missing repositories always report `PARTIAL` rather than guessing.
49
+ > - **Recommended rollout:** Run Butterfly in **report-only CI mode first** (`butterfly check` without `--strict`, `continue-on-error: true` or artifact-only PR summaries) to calibrate limitations before enforcing blocking `--strict` gates.
50
+
51
+ ```
52
+ BUTTERFLY
53
+ Software Change Intelligence
54
+
55
+ Comparison: main -> HEAD
56
+ Analysis status: PARTIAL
57
+
58
+ Change: signature_changed app.services.payments.process_payment
59
+ HIGH app.services.orders.create_order
60
+ path: app.services.orders.create_order -calls-> app.services.payments.process_payment
61
+ evidence: app/services/orders.py:12 (statically resolved)
62
+ consequence: confirmed_dependency
63
+
64
+ UNKNOWN Dynamic API consumer
65
+ app.clients.checkout_client.submit_checkout_dynamic cannot be linked:
66
+ request URL is not a string literal.
67
+
68
+ Policy verdict: WARN
69
+ Next action: review unresolved dependencies, then run the selected tests.
70
+ ```
71
+
72
+ (The text above is the shape of the human report; the true output on the bundled
73
+ fixture is in [Quick start](#quick-start).)
74
+
75
+ ## The problem it solves
76
+
77
+ Review shows a diff. A one-line change to a default parameter, a dropped response
78
+ field or a renamed configuration key can break a consumer nobody in the thread
79
+ remembers. The information needed to judge the change is spread across call sites,
80
+ SQL, migrations, OpenAPI documents, configuration, events, workers and tests.
81
+
82
+ Butterfly assembles that information into a typed consequence graph, propagates the
83
+ change along only the relationships that matter for *that kind* of change, and
84
+ attaches evidence to every claim.
85
+
86
+ ## What Butterfly does
87
+
88
+ - Parses Python with the standard library `ast` (no execution, no imports).
89
+ - Resolves modules, imports, aliases, classes, inheritance and calls using
90
+ documented rules, and records everything it cannot resolve.
91
+ - Builds a typed graph of code **plus** endpoints, database tables and columns,
92
+ configuration keys, events and declared business workflows.
93
+ - Compares two Git snapshots semantically: added/removed/changed functions, changed
94
+ signatures, removed columns, removed response fields, removed configuration
95
+ declarations, non-semantic (formatting/docstring) edits.
96
+ - Propagates consequences with per-change-type rules and bounded traversal.
97
+ - Attaches evidence: the edge path, source locations, resolution grade, rule id.
98
+ - Reports uncertainty as a first-class status (`COMPLETE` / `PARTIAL`), with blocking
99
+ limitation codes.
100
+ - Evaluates a separate policy layer (`PASS` / `WARN` / `FAIL` / `UNKNOWN`) with
101
+ documented exit codes.
102
+ - Plans affected tests — without running them — and escalates to "full suite
103
+ required" when the evidence is insufficient.
104
+ - Imports bounded OpenTelemetry, coverage (`coverage-json`, `lcov`, `istanbul`), and
105
+ service dependency telemetry (`butterfly evidence`), fusing verified non-stale
106
+ evidence cleanly without inflating static confidence.
107
+ - Federates multi-repository workspaces (`.butterfly-workspace.json`, `butterfly workspace`)
108
+ across Python and TypeScript services, OpenAPI endpoints, event topics, and SDK manifests.
109
+ - Enforces declarative architectural layers, isolation, and cycle rules with baseline
110
+ diffing (`butterfly architecture`), plus bounded Git history trends (`butterfly history`,
111
+ `butterfly evolution`).
112
+ - Simulates a patch or a symbol removal in memory, without touching the working
113
+ tree, and can compare two candidate patches.
114
+ - Emits human, JSON, Markdown and SARIF reports deterministically.
115
+
116
+ ## What Butterfly does **not** do
117
+
118
+ - It does not execute the analysed repository: no imports, no test runs, no
119
+ migrations.
120
+ - It does not send source, secrets, Git metadata or results anywhere. No telemetry,
121
+ no API key, no network.
122
+ - It does not claim a change is safe. A policy `PASS` means "the configured rules
123
+ were satisfied".
124
+ - It does not infer arbitrary runtime types or resolve dynamic dispatch; dynamic
125
+ constructs stay explicitly unresolved.
126
+ - Languages outside Python, TypeScript/JavaScript (via optional non-executing Compiler API backend),
127
+ SQL, OpenAPI JSON, and supported config formats are counted as `unsupported` and force `PARTIAL`.
128
+ - It does not prove that unselected tests cannot fail.
129
+
130
+ ## Installation (2-Minute Setup)
131
+
132
+ Requires **Python 3.11+** and **Git** on `PATH`. Zero third-party Python runtime dependencies (`dependencies = []` in `pyproject.toml`).
133
+
134
+ ```bash
135
+ # Option A: Install release package (or local wheel / editable checkout)
136
+ pip install "butterfly-change-intelligence==0.5.0b1" # or: pip install -e .
137
+ butterfly --version
138
+ butterfly init
139
+
140
+ # Option B: Optional TypeScript / JavaScript backend (isolated Node host, non-executing)
141
+ npm --prefix .butterfly-backends/ts install --ignore-scripts --no-save --no-audit --no-fund typescript@5.9.3
142
+ butterfly backend doctor typescript
143
+
144
+ # Option C: Run directly from checkout without install
145
+ cd /path/to/butterfly
146
+ python -m butterfly --version
147
+ python -m butterfly --path /path/to/your/repo status
148
+ ```
149
+
150
+ ### Compatibility Matrix
151
+
152
+ | Component | Supported / Minimum | Verified Environments | Notes |
153
+ |---|---|---|---|
154
+ | **Python** | `>= 3.11` | `3.11`, `3.13` (Ubuntu, Windows, macOS CI); `3.14.3` (Windows 11 local) | Pure Python stdlib core; `0` third-party PyPI runtime dependencies |
155
+ | **OS** | Linux, Windows, macOS | GitHub Actions `ubuntu-latest`, `windows-latest`, `macos-latest` | Tested with `core.autocrlf` variations; Windows symlink test skips cleanly |
156
+ | **Node / TS (Optional)** | Node LTS + `typescript@5.9.3` | Node `v24.14.1` + `typescript@5.9.3` (local); `typescript@5.9.3` across all CI OSes | Only needed for `.ts`/`.tsx`/`.js`/`.jsx` analysis; degrades explicitly to `PARTIAL` if absent |
157
+ | **Git** | Modern Git CLI (`cat-file --batch`) | Standard Ubuntu/macOS/Windows Git | Strictly read-only plumbing; hooks, fsmonitor, and diff drivers disabled |
158
+
159
+ Build and distribution artifacts (wheel + sdist) are validated via `python -m build --no-isolation` and `twine check dist/*`.
160
+
161
+ ## Quick start
162
+
163
+ Run these from the repository root. The bundled fixture is **not** a Git repository,
164
+ so the read-only commands work in place and the comparison commands need a
165
+ two-commit copy:
166
+
167
+ ```bash
168
+ # 1. Inspect the bundled fixture in place
169
+ python -m butterfly --path fixtures/butterfly-commerce-lab index
170
+ python -m butterfly --path fixtures/butterfly-commerce-lab status
171
+ python -m butterfly --path fixtures/butterfly-commerce-lab coverage
172
+
173
+ # 2. Make a two-commit copy and analyse a real change
174
+ cp -r fixtures/butterfly-commerce-lab /tmp/butterfly-lab
175
+ cd /tmp/butterfly-lab
176
+ git init -q && git add -A && git -c user.email=dev@example.com -c user.name=dev commit -qm base
177
+ sed -i 's/def process_payment(order_id, amount/def process_payment(order_id/' app/services/payments.py
178
+ git add -A && git -c user.email=dev@example.com -c user.name=dev commit -qm 'drop amount parameter'
179
+ cd - # back to the Butterfly checkout
180
+
181
+ python -m butterfly --path /tmp/butterfly-lab init
182
+ python -m butterfly --path /tmp/butterfly-lab analyze --base HEAD~1 --head HEAD
183
+ python -m butterfly --path /tmp/butterfly-lab explain IMPACT-0001
184
+ python -m butterfly --path /tmp/butterfly-lab tests --base HEAD~1 --head HEAD
185
+ python -m butterfly --path /tmp/butterfly-lab check --base HEAD~1 --head HEAD --strict # exit 4
186
+ ```
187
+
188
+ On that copy, `analyze` reports `status: PARTIAL` (the fixture contains a dynamic SQL
189
+ statement and a dynamic API consumer), `check --strict` therefore exits 4, and
190
+ `analyze` without `--strict` lists the affected callers, endpoint, workflows and
191
+ tests.
192
+
193
+ To try it on your own repository:
194
+
195
+ ```bash
196
+ cd /path/to/your/repo
197
+ python -m butterfly init
198
+ python -m butterfly analyze --base origin/main --head HEAD
199
+ python -m butterfly tests --base origin/main --head HEAD
200
+ python -m butterfly check --base origin/main --head HEAD --strict
201
+ ```
202
+
203
+ ### Commands
204
+
205
+ | Command | Purpose |
206
+ |---|---|
207
+ | `init` | create configuration, policy, workflow manifests |
208
+ | `doctor` | check Python, Git, config, policy, cache, index |
209
+ | `index` | analyse the working tree and store the graph |
210
+ | `status` | index/cache/last-analysis state (read-only) |
211
+ | `analyze` | analyse a change and report consequences |
212
+ | `diff` | semantic changes only |
213
+ | `impact` | dependents of a symbol or file |
214
+ | `explain` | explain one finding from the last analysis |
215
+ | `slice` | export a bounded, secret-redacted evidence slice for one finding |
216
+ | `graph` | export the graph (`--format dot|json`) |
217
+ | `coverage` | analysis coverage metrics |
218
+ | `tests` | test selection plan |
219
+ | `simulate` | hypothetical patch or symbol removal |
220
+ | `compare` | compare consequences of two patches |
221
+ | `policy` | re-evaluate policy (`check`, supports `--strict-warn`) |
222
+ | `check` | analyse + policy, the CI entry point |
223
+ | `report` | re-render the last analysis |
224
+ | `cache` | `status` / `clear` |
225
+ | `backend` | inspect optional adapter backend readiness (`doctor` / `status`) |
226
+ | `evidence` | import, validate, list, inspect, status, and clear runtime telemetry/coverage |
227
+ | `workspace` | multi-repository federation (`init`, `validate`, `status`, `index`, `analyze`, `graph`) |
228
+ | `architecture` | architectural layer/isolation/cycle governance (`check`, `diff`, `explain`, `cycles`, `report`) |
229
+ | `history` | bounded Git entity change timeline |
230
+ | `evolution` | structural deltas & co-change correlations across commits |
231
+ | `version` | versions and schema versions |
232
+
233
+ Full contract: [docs/CLI_SPECIFICATION.md](docs/CLI_SPECIFICATION.md).
234
+
235
+ ### Exit codes
236
+
237
+ | Code | Meaning |
238
+ |---|---|
239
+ | 0 | success, policy satisfied |
240
+ | 1 | policy violation (`FAIL`) |
241
+ | 2 | invalid invocation or configuration |
242
+ | 3 | internal or operational failure |
243
+ | 4 | incomplete analysis prevents the decision (`UNKNOWN` with `--strict`/`--require-complete`) |
244
+
245
+ ## Example: a removed parameter
246
+
247
+ Fixture `signature-change` removes a required parameter from
248
+ `app.services.payments.process_payment`. Actual measured output (`--format json`,
249
+ summarised):
250
+
251
+ ```json
252
+ {
253
+ "status": "PARTIAL",
254
+ "change_set": {"changes": [
255
+ {"category": "signature_changed",
256
+ "qualname": "app.services.payments.process_payment"},
257
+ {"category": "body_changed",
258
+ "qualname": "app.services.payments.process_payment"}]},
259
+ "impact": {"summary": {
260
+ "findings": 7, "high_severity": 4,
261
+ "affected_workflows": ["checkout", "payment-settlement"]}},
262
+ "tests": {"selected": [
263
+ "tests.test_payments.test_process_payment_records_amount",
264
+ "tests.test_order_creation..."]}
265
+ }
266
+ ```
267
+
268
+ Each finding carries its path, e.g.
269
+ `app.services.orders.create_order -calls-> process_payment`, with the location of
270
+ the call site and `resolution: resolved`. `butterfly explain IMPACT-0001` prints the
271
+ same evidence in prose derived from the structured data — no language model is
272
+ involved.
273
+
274
+ ## Supported languages
275
+
276
+ | Language | Status |
277
+ |---|---|
278
+ | Python | supported (stdlib `ast`, `ADAPTER_VERSION = 0.5.1`) |
279
+ | TypeScript / JavaScript | supported via optional isolated Node Compiler API host (`typescript@5.9.3`, zero target execution; missing backend degrades cleanly to `PARTIAL`) |
280
+ | SQL | documented subset (DDL/DML for schema and query dependencies) |
281
+ | OpenAPI | JSON only, documented subset (YAML emits explicit limitation note) |
282
+ | Configuration (`.env`, `.ini`, `.json`, `.toml`) | keys only, secret values redacted |
283
+ | Anything else | discovered, classified `unsupported`, counted, forces `PARTIAL` |
284
+
285
+ Full capability matrix, including what is *not* supported and why:
286
+ [docs/LANGUAGE_SUPPORT.md](docs/LANGUAGE_SUPPORT.md).
287
+
288
+ ## Architecture
289
+
290
+ ```mermaid
291
+ flowchart LR
292
+ S["Read-Only Snapshots (fs | Git index | git cat-file | overlay)"] --> E["Non-Executing Extractors (Python AST | Isolated TS CompilerHost | SQL/OpenAPI/Config)"]
293
+ E --> R["Deterministic Resolver & Unresolved Ledger"]
294
+ R --> G["Typed Consequence Graph (16 node kinds, 15 edge kinds)"]
295
+ G --> SD["Semantic Git Diff"]
296
+ SD --> IP["Per-Rule Consequence Propagation + Evidence Paths"]
297
+ E --> U["Uncertainty Tracker (COMPLETE / PARTIAL)"]
298
+ G --> IP
299
+ U --> P["Policy Engine & Test Selection Plan"]
300
+ IP --> P
301
+ P --> OUT["Human / JSON / Markdown / SARIF + Bounded Evidence Slices"]
302
+ ```
303
+
304
+ Butterfly separates **graph/evidence truth**, **analysis completeness (`COMPLETE` / `PARTIAL`)**, and **policy verdicts (`PASS` / `WARN` / `FAIL` / `UNKNOWN`)**. See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md),
305
+ [docs/GRAPH_MODEL.md](docs/GRAPH_MODEL.md), and [docs/DOMAIN_MODEL.md](docs/DOMAIN_MODEL.md).
306
+
307
+ ## CI integration
308
+
309
+ Start with **report-only CI integration** (non-blocking PR artifacts / SARIF) so teams can inspect `PARTIAL` limitation codes and unresolved dynamic sites before enabling `--strict`:
310
+
311
+ ```yaml
312
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
313
+ with: {fetch-depth: 0} # merge-base comparison needs history
314
+ - run: pip install "butterfly-change-intelligence==0.5.0b1"
315
+ - name: Report-only consequence check (recommended starting point)
316
+ continue-on-error: true
317
+ run: butterfly check --base origin/${{ github.base_ref }} --head HEAD --format sarif --output butterfly.sarif
318
+ ```
319
+
320
+ Once your codebase boundaries are clean, add `--strict` to fail builds (exit `4`) when `status == PARTIAL`.
321
+ Shallow clones: pass `--base` with a fetched ref, or run `git fetch --deepen`.
322
+ Missing base commits produce exit 2 with a message, never a silent empty analysis.
323
+ A ready-to-copy sample workflow is in `.github/workflows/butterfly-pr.yml`.
324
+
325
+ ## Security and privacy
326
+
327
+ - No network I/O during analysis; no telemetry; no API key.
328
+ - No repository code is executed, imported or tested.
329
+ - Git is used read-only with a fixed argument template; hooks, fsmonitor and
330
+ external diff drivers are disabled.
331
+ - Paths are validated against the analysis root; escapes are refused.
332
+ - Reports contain paths, line numbers, identifiers and verdicts — never source
333
+ excerpts or configuration values.
334
+ - Caches contain analysis facts (identifiers, hashes, locations) and can be deleted
335
+ at any time.
336
+
337
+ Limitations are enumerated in [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md) §4
338
+ (residual risks) and reported in [SECURITY.md](SECURITY.md).
339
+
340
+ ## Performance
341
+
342
+ Measured on Windows 11, AMD Ryzen-class 12-thread CPU, CPython 3.14.3
343
+ (`benchmarks/bench.py` and `benchmarks/scale_1m.py`):
344
+
345
+ | Workload | Result |
346
+ |---|---|
347
+ | Fixture analysis, cold cache / warm cache / no cache | see [docs/PERFORMANCE.md](docs/PERFORMANCE.md) |
348
+ | 1,000,000-node chain build + reverse BFS + Tarjan SCC (`scale_1m.py`) | 28.235 s build, 0.00029 s BFS, 5.455 s SCC, 763.5 MB peak traced memory |
349
+ | Memory retention over 8 repeated multi-repo workspace/evidence runs | < 8 MB retained growth, < 64 MB peak (`tests/test_performance_retention.py`) |
350
+
351
+ Full method, hardware, and synthetic 50k/100k shape numbers: [docs/PERFORMANCE.md](docs/PERFORMANCE.md).
352
+
353
+ ## Accuracy
354
+
355
+ Empirical call-site & commit evaluation across three frozen SHA-256 corpora
356
+ (`benchmarks/eval_external.py`, `benchmarks/eval_ts_external.py`, `benchmarks/eval_fresh.py`):
357
+
358
+ - **External Python (`requests`, `click`, `httpx`, `flask`, `fastapi` — 320 sites, 52 commits):** overall F1 `0.9774` (`held_out P=1.0000, R=0.9875, F1=0.9937`, `0/34` unknown FPs), commit `semAcc=0.9808`.
359
+ - **External TypeScript/JS (`zod`, `commander`, `got`, `hono` — 367 sites, 51 commits):** overall `P=0.9664, R=0.9600, F1=0.9632`, `held_out F1=0.9600` (`0/67` unknown FPs), commit `semAcc=0.9804` (`held_out=1.0000`, `0` parse errors across 1,217 files).
360
+ - **Fresh Unseen Holdout (`jinja`, `anyio`, `ky`, `ufo`, `immer`, `ofetch`, `marked` — 555 sites, 116 commits):** overall `P=0.9661, R=0.9415, F1=0.9536`, **`0/89` unknown FPs** (`immer`/`ky`/`marked` `1.0000` F1); untouched baseline commits `semAcc=0.8534` (`evPath=1.0000`, `0` parse errors), rising to `semAcc=0.8793` (`noop=21/27`, `fileR=0.8365`) after general TypeScript barrel-export and `.github/` workflow fixes.
361
+
362
+ ## Known limitations
363
+
364
+ 1. **Dynamic dispatch & dynamic imports stay unresolved.** Butterfly refuses to guess dynamic calls (`obj[k]()`, `import_module(var)`), which keeps precision high (`0` unknown FPs on 190 unseen dynamic sites across all three corpora) while flagging incomplete visibility as `PARTIAL`.
365
+ 2. **Comment/JSDoc edits & out-of-root paths.** Butterfly intentionally classifies comment-only, formatting-only, and JSDoc-only edits as semantically neutral; CI/GitHub workflow metadata under `.github/` is excluded from runtime `CONFIG_KEY` extraction.
366
+ 3. **Contract & schema depth.** OpenAPI `$ref` external chains and YAML OpenAPI bodies remain out of scope (YAML contracts emit an explicit note); SQL parses a conservative DDL/DML subset.
367
+ 4. **Scoped vs repo completeness.** `--strict` enforces repo-wide completeness (exits `4` if any unresolved item exists); PR workflows can use `--scope change --require-complete` while keeping global `PARTIAL` visible.
368
+ 5. **Artifact verification status.** SHA-256 checksums, CycloneDX 1.5 SBOM (`docs/sbom.cdx.json`), and a release provenance manifest are produced; cryptographic artifact signatures (Sigstore/GPG) remain future work. See [docs/engineering/RELEASE_GATES.md](docs/engineering/RELEASE_GATES.md).
369
+
370
+ ## Roadmap
371
+
372
+ See [docs/ROADMAP.md](docs/ROADMAP.md). Next: expanded schema migrations (Protobuf/GraphQL), OpenAPI external `$ref` and YAML support, plus deeper framework/container filtering controls.
373
+
374
+ ## Contributing
375
+
376
+ [docs/engineering/ENGINEERING_STANDARDS.md](docs/engineering/ENGINEERING_STANDARDS.md)
377
+ and [CONTRIBUTING.md](CONTRIBUTING.md). Tests first, evidence over adjectives.
378
+
379
+ ## License
380
+
381
+ Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).