diffgenome 0.1.0__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.
- diffgenome-0.1.0/.gitignore +12 -0
- diffgenome-0.1.0/LICENSE +202 -0
- diffgenome-0.1.0/PKG-INFO +139 -0
- diffgenome-0.1.0/README.md +118 -0
- diffgenome-0.1.0/fixtures/exp01_shop/README.md +37 -0
- diffgenome-0.1.0/fixtures/exp01_shop/groundtruth/test_end_to_end.py +38 -0
- diffgenome-0.1.0/fixtures/exp01_shop/pytest.ini +5 -0
- diffgenome-0.1.0/fixtures/exp01_shop/shop/__init__.py +0 -0
- diffgenome-0.1.0/fixtures/exp01_shop/shop/controller.py +12 -0
- diffgenome-0.1.0/fixtures/exp01_shop/shop/inventory_service.py +16 -0
- diffgenome-0.1.0/fixtures/exp01_shop/shop/order_service.py +28 -0
- diffgenome-0.1.0/fixtures/exp01_shop/shop/price_repository.py +12 -0
- diffgenome-0.1.0/fixtures/exp01_shop/shop/pricing_service.py +14 -0
- diffgenome-0.1.0/fixtures/exp01_shop/tests/test_controller.py +29 -0
- diffgenome-0.1.0/fixtures/exp01_shop/tests/test_order_service.py +28 -0
- diffgenome-0.1.0/fixtures/exp01_shop/tests/test_pricing_service.py +19 -0
- diffgenome-0.1.0/fixtures/exp07_state/README.md +15 -0
- diffgenome-0.1.0/fixtures/exp07_state/groundtruth/test_end_to_end.py +29 -0
- diffgenome-0.1.0/fixtures/exp07_state/proc/__init__.py +0 -0
- diffgenome-0.1.0/fixtures/exp07_state/proc/pipeline.py +10 -0
- diffgenome-0.1.0/fixtures/exp07_state/proc/processor.py +32 -0
- diffgenome-0.1.0/fixtures/exp07_state/proc/repository.py +14 -0
- diffgenome-0.1.0/fixtures/exp07_state/proc/settings.py +1 -0
- diffgenome-0.1.0/fixtures/exp07_state/pytest.ini +6 -0
- diffgenome-0.1.0/fixtures/exp07_state/tests/__init__.py +0 -0
- diffgenome-0.1.0/fixtures/exp07_state/tests/test_pipeline.py +17 -0
- diffgenome-0.1.0/fixtures/exp07_state/tests/test_processor.py +26 -0
- diffgenome-0.1.0/pyproject.toml +70 -0
- diffgenome-0.1.0/src/diffgenome/__init__.py +7 -0
- diffgenome-0.1.0/src/diffgenome/__main__.py +240 -0
- diffgenome-0.1.0/src/diffgenome/_collectors/go/dg/dg.go +623 -0
- diffgenome-0.1.0/src/diffgenome/_collectors/go/go.mod +3 -0
- diffgenome-0.1.0/src/diffgenome/_collectors/go/instrument/facts.go +346 -0
- diffgenome-0.1.0/src/diffgenome/_collectors/go/instrument/main.go +484 -0
- diffgenome-0.1.0/src/diffgenome/_collectors/node/instrument.js +289 -0
- diffgenome-0.1.0/src/diffgenome/_collectors/node/jest-setup.js +40 -0
- diffgenome-0.1.0/src/diffgenome/_collectors/node/package-lock.json +35 -0
- diffgenome-0.1.0/src/diffgenome/_collectors/node/package.json +11 -0
- diffgenome-0.1.0/src/diffgenome/_collectors/node/runtime.js +426 -0
- diffgenome-0.1.0/src/diffgenome/ambiguity.py +122 -0
- diffgenome-0.1.0/src/diffgenome/api.py +67 -0
- diffgenome-0.1.0/src/diffgenome/change.py +86 -0
- diffgenome-0.1.0/src/diffgenome/change_artifact.py +310 -0
- diffgenome-0.1.0/src/diffgenome/collect/__init__.py +2 -0
- diffgenome-0.1.0/src/diffgenome/collect/go_test.py +271 -0
- diffgenome-0.1.0/src/diffgenome/collect/node_jest.py +319 -0
- diffgenome-0.1.0/src/diffgenome/collect/py_monitoring.py +985 -0
- diffgenome-0.1.0/src/diffgenome/collect/py_runtime.py +116 -0
- diffgenome-0.1.0/src/diffgenome/collect/py_symbols.py +238 -0
- diffgenome-0.1.0/src/diffgenome/collect/pytest_plugin.py +130 -0
- diffgenome-0.1.0/src/diffgenome/compose.py +469 -0
- diffgenome-0.1.0/src/diffgenome/dependence.py +264 -0
- diffgenome-0.1.0/src/diffgenome/evaluate.py +669 -0
- diffgenome-0.1.0/src/diffgenome/frontends/__init__.py +0 -0
- diffgenome-0.1.0/src/diffgenome/frontends/python_ir.py +335 -0
- diffgenome-0.1.0/src/diffgenome/genome.py +1016 -0
- diffgenome-0.1.0/src/diffgenome/genome_pipeline.py +674 -0
- diffgenome-0.1.0/src/diffgenome/genome_prompt.py +33 -0
- diffgenome-0.1.0/src/diffgenome/genome_state.py +2118 -0
- diffgenome-0.1.0/src/diffgenome/graph.py +426 -0
- diffgenome-0.1.0/src/diffgenome/llm.py +189 -0
- diffgenome-0.1.0/src/diffgenome/model.py +364 -0
- diffgenome-0.1.0/src/diffgenome/mvp.py +398 -0
- diffgenome-0.1.0/src/diffgenome/probe.py +509 -0
- diffgenome-0.1.0/src/diffgenome/projection.py +308 -0
- diffgenome-0.1.0/src/diffgenome/py.typed +0 -0
- diffgenome-0.1.0/src/diffgenome/render.py +118 -0
- diffgenome-0.1.0/src/diffgenome/report.py +363 -0
- diffgenome-0.1.0/src/diffgenome/resolve.py +37 -0
- diffgenome-0.1.0/src/diffgenome/runtime.py +74 -0
- diffgenome-0.1.0/src/diffgenome/runtime_evidence.py +261 -0
- diffgenome-0.1.0/src/diffgenome/sandbox.py +166 -0
- diffgenome-0.1.0/src/diffgenome/serialize.py +96 -0
- diffgenome-0.1.0/src/diffgenome/sites.py +19 -0
- diffgenome-0.1.0/src/diffgenome/static_types.py +69 -0
- diffgenome-0.1.0/src/diffgenome/structure.py +462 -0
- diffgenome-0.1.0/tests/__init__.py +0 -0
- diffgenome-0.1.0/tests/test_change_artifact.py +72 -0
- diffgenome-0.1.0/tests/test_collector.py +299 -0
- diffgenome-0.1.0/tests/test_exp01.py +319 -0
- diffgenome-0.1.0/tests/test_exp07.py +346 -0
- diffgenome-0.1.0/tests/test_exp10.py +198 -0
- diffgenome-0.1.0/tests/test_fixture_repos.py +20 -0
- diffgenome-0.1.0/tests/test_genome.py +151 -0
- diffgenome-0.1.0/tests/test_genome_pipeline.py +77 -0
- diffgenome-0.1.0/tests/test_mechanics.py +318 -0
- diffgenome-0.1.0/tests/test_model.py +57 -0
- diffgenome-0.1.0/tests/test_mvp.py +136 -0
- diffgenome-0.1.0/tests/test_occurrence_binding.py +161 -0
- diffgenome-0.1.0/tests/test_outcome_boundary.py +227 -0
- diffgenome-0.1.0/tests/test_packaging.py +24 -0
- diffgenome-0.1.0/tests/test_rev_index.py +41 -0
- diffgenome-0.1.0/tests/test_runtime_evidence.py +145 -0
- diffgenome-0.1.0/tests/test_structure.py +170 -0
- diffgenome-0.1.0/tests/test_value_identity.py +286 -0
diffgenome-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: diffgenome
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Runtime evidence for code changes: run a repository's existing tests against a change and report what actually executed.
|
|
5
|
+
Author: karims
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: change impact,code review,runtime evidence,test mapping,tracing
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
16
|
+
Classifier: Topic :: Software Development :: Testing
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Provides-Extra: genome
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# diffgenome
|
|
23
|
+
|
|
24
|
+
**Runtime evidence for code changes.** diffgenome runs a repository's *existing* tests against a
|
|
25
|
+
change, records what actually executes, and reports it as a small, versioned JSON contract
|
|
26
|
+
(`diffgenome-runtime/1`) that a reviewer or a review tool can consume.
|
|
27
|
+
|
|
28
|
+
It answers questions static analysis and models can only guess at:
|
|
29
|
+
|
|
30
|
+
- Which changed functions did the existing tests actually execute, and in **exactly which tests
|
|
31
|
+
and subtests**?
|
|
32
|
+
- Through which call chains did execution reach the changed code, including dynamic dispatch,
|
|
33
|
+
registries and decorators the static call graph cannot follow?
|
|
34
|
+
- Which **outcomes** of each changed condition were observed (true / false / never evaluated)?
|
|
35
|
+
- How did the changed code exit (returned, returned-error, raised `<type>`), and with which
|
|
36
|
+
argument type shapes?
|
|
37
|
+
- Where did observation stop: mocks, fakes, eager task runners, external systems?
|
|
38
|
+
- Which changed behavior did **no existing test exercise**?
|
|
39
|
+
|
|
40
|
+
No model is involved. Everything reported was observed, or is a static decision site needed to
|
|
41
|
+
place an observed outcome on a changed line.
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install diffgenome
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Python 3.12+ (the Python tracer uses `sys.monitoring`). No runtime dependencies. Language
|
|
50
|
+
support:
|
|
51
|
+
|
|
52
|
+
| target | tests run with | needs |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| Python | pytest | the target's virtualenv (`--python`) |
|
|
55
|
+
| Go | `go test` | a Go toolchain with the module's dependencies available offline |
|
|
56
|
+
| Node / TypeScript | Jest | the target's `node_modules` (TypeScript is taken from there, or from `DIFFGENOME_NODE_PATH`) |
|
|
57
|
+
|
|
58
|
+
Tests run inside a disposable copy of the repository (never the checkout itself), under a
|
|
59
|
+
sandbox with no network unless `--allow-loopback` is given for local test services.
|
|
60
|
+
|
|
61
|
+
## Use
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Python: the change between two revisions, the tests that cover it
|
|
65
|
+
diffgenome change --runtime python --repo . --python .venv/bin/python \
|
|
66
|
+
--source-root src --test-root tests --diff main..HEAD --out .diffgenome/run
|
|
67
|
+
|
|
68
|
+
# Go
|
|
69
|
+
diffgenome change --runtime go --repo . --test-root api --tests ./api/ \
|
|
70
|
+
--mock-dir db/mock --diff main..HEAD --out .diffgenome/run
|
|
71
|
+
|
|
72
|
+
# analyze a revision other than the checkout, without touching the checkout
|
|
73
|
+
diffgenome change ... --rev <head> --diff <base>..<head>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The result is `.diffgenome/run/diffgenome-change.json`. Its `runtime` section is the contract:
|
|
77
|
+
|
|
78
|
+
```jsonc
|
|
79
|
+
{
|
|
80
|
+
"format": "diffgenome-runtime/1",
|
|
81
|
+
"universe": { "test_scope": "tests/", "executions": 55, "passed": 55, "failed": 0, "tests": [...] },
|
|
82
|
+
"changed_functions": [{
|
|
83
|
+
"symbol": "py:app.rows.handler.RowHandler.restore_row", "file": "...", "line": 3221, "origin": "repo",
|
|
84
|
+
"executed": true, "calls": 3, "tests": ["...::test_editor_can_redo_create_row", "..."],
|
|
85
|
+
"exits": { "returned": 3 }, "raised_inside": {}, "arg_shapes": [[["user", "User"], ["row_id", "int"]]],
|
|
86
|
+
"callers": [{ "symbol": "...DeleteRowActionType.undo", "calls": 2, "tests": 2 }],
|
|
87
|
+
"stand_ins": {},
|
|
88
|
+
"changed_sites": [{ "line": 3240, "predicate": "view is None", "true": 0, "false": 3 }]
|
|
89
|
+
}],
|
|
90
|
+
"edges": [{ "caller": {...}, "callee": {...}, "executions": 2, "tests": [...], "tests_total": 2 }],
|
|
91
|
+
"boundaries": [{ "kind": "external", "caller": "...", "target": "celery.canvas._chord" }],
|
|
92
|
+
"gaps": [
|
|
93
|
+
{ "kind": "function_not_executed", "symbol": "...TrashHandler.restore_item" },
|
|
94
|
+
{ "kind": "branch_outcome_not_observed", "line": 217, "predicate": "not fields", "outcome": "true" },
|
|
95
|
+
{ "kind": "stand_in_reached", "target": "...FormulaFieldType.run_periodic_update" }
|
|
96
|
+
],
|
|
97
|
+
"not_reported": ["values (only type shapes and opaque fingerprints are recorded)",
|
|
98
|
+
"except-handler coverage (handlers are not decision sites)", "per-line coverage"]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Every "not executed" is relative to `universe.test_scope`: the tests that were run. Locations
|
|
103
|
+
carry `origin` (`repo`, `test`, `external`) so a consumer can tell application frames from test
|
|
104
|
+
frames.
|
|
105
|
+
|
|
106
|
+
The artifact's other sections (`nodes`, `edges`, `executions`, `boundaries`, `facts`) describe
|
|
107
|
+
the observed behavioral neighborhood of the change; `report.md` and `behavioral-map.md` render
|
|
108
|
+
it for people.
|
|
109
|
+
|
|
110
|
+
## Consumers
|
|
111
|
+
|
|
112
|
+
[Sydes](https://pypi.org/project/sydes/) uses the runtime contract for change verification:
|
|
113
|
+
observed call edges join its call graph for reachability, the exact tests per changed function
|
|
114
|
+
become supporting test evidence, the gaps become verification gaps, and AI recovery is only asked
|
|
115
|
+
about what the runtime evidence cannot answer. Sydes depends on the contract alone, not on
|
|
116
|
+
diffgenome internals.
|
|
117
|
+
|
|
118
|
+
## Optional: the Behavioral Genome (research)
|
|
119
|
+
|
|
120
|
+
`diffgenome genome` builds a semantic layer on top of the runtime evidence: a model proposes
|
|
121
|
+
behavioral rules (variables, decisions, transitions), and a deterministic checker keeps only the
|
|
122
|
+
rules the observed executions verify or support. It is optional research code: nothing in
|
|
123
|
+
`diffgenome change` or the runtime contract uses it, and it needs no extra packages (an OpenAI
|
|
124
|
+
key only for live proposals, read from `OPENAI_API_KEY` or `~/.config/diffgenome/openai_api_key`).
|
|
125
|
+
Install with `pip install "diffgenome[genome]"` to state the intent. See
|
|
126
|
+
`docs/research-overview.md` and `docs/runtime-evaluation.md` for what has and has not been
|
|
127
|
+
shown to work.
|
|
128
|
+
|
|
129
|
+
## Development
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
uv sync
|
|
133
|
+
uv run pytest
|
|
134
|
+
uv run ruff check src tests && uv run mypy src
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# diffgenome
|
|
2
|
+
|
|
3
|
+
**Runtime evidence for code changes.** diffgenome runs a repository's *existing* tests against a
|
|
4
|
+
change, records what actually executes, and reports it as a small, versioned JSON contract
|
|
5
|
+
(`diffgenome-runtime/1`) that a reviewer or a review tool can consume.
|
|
6
|
+
|
|
7
|
+
It answers questions static analysis and models can only guess at:
|
|
8
|
+
|
|
9
|
+
- Which changed functions did the existing tests actually execute, and in **exactly which tests
|
|
10
|
+
and subtests**?
|
|
11
|
+
- Through which call chains did execution reach the changed code, including dynamic dispatch,
|
|
12
|
+
registries and decorators the static call graph cannot follow?
|
|
13
|
+
- Which **outcomes** of each changed condition were observed (true / false / never evaluated)?
|
|
14
|
+
- How did the changed code exit (returned, returned-error, raised `<type>`), and with which
|
|
15
|
+
argument type shapes?
|
|
16
|
+
- Where did observation stop: mocks, fakes, eager task runners, external systems?
|
|
17
|
+
- Which changed behavior did **no existing test exercise**?
|
|
18
|
+
|
|
19
|
+
No model is involved. Everything reported was observed, or is a static decision site needed to
|
|
20
|
+
place an observed outcome on a changed line.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install diffgenome
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Python 3.12+ (the Python tracer uses `sys.monitoring`). No runtime dependencies. Language
|
|
29
|
+
support:
|
|
30
|
+
|
|
31
|
+
| target | tests run with | needs |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| Python | pytest | the target's virtualenv (`--python`) |
|
|
34
|
+
| Go | `go test` | a Go toolchain with the module's dependencies available offline |
|
|
35
|
+
| Node / TypeScript | Jest | the target's `node_modules` (TypeScript is taken from there, or from `DIFFGENOME_NODE_PATH`) |
|
|
36
|
+
|
|
37
|
+
Tests run inside a disposable copy of the repository (never the checkout itself), under a
|
|
38
|
+
sandbox with no network unless `--allow-loopback` is given for local test services.
|
|
39
|
+
|
|
40
|
+
## Use
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Python: the change between two revisions, the tests that cover it
|
|
44
|
+
diffgenome change --runtime python --repo . --python .venv/bin/python \
|
|
45
|
+
--source-root src --test-root tests --diff main..HEAD --out .diffgenome/run
|
|
46
|
+
|
|
47
|
+
# Go
|
|
48
|
+
diffgenome change --runtime go --repo . --test-root api --tests ./api/ \
|
|
49
|
+
--mock-dir db/mock --diff main..HEAD --out .diffgenome/run
|
|
50
|
+
|
|
51
|
+
# analyze a revision other than the checkout, without touching the checkout
|
|
52
|
+
diffgenome change ... --rev <head> --diff <base>..<head>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The result is `.diffgenome/run/diffgenome-change.json`. Its `runtime` section is the contract:
|
|
56
|
+
|
|
57
|
+
```jsonc
|
|
58
|
+
{
|
|
59
|
+
"format": "diffgenome-runtime/1",
|
|
60
|
+
"universe": { "test_scope": "tests/", "executions": 55, "passed": 55, "failed": 0, "tests": [...] },
|
|
61
|
+
"changed_functions": [{
|
|
62
|
+
"symbol": "py:app.rows.handler.RowHandler.restore_row", "file": "...", "line": 3221, "origin": "repo",
|
|
63
|
+
"executed": true, "calls": 3, "tests": ["...::test_editor_can_redo_create_row", "..."],
|
|
64
|
+
"exits": { "returned": 3 }, "raised_inside": {}, "arg_shapes": [[["user", "User"], ["row_id", "int"]]],
|
|
65
|
+
"callers": [{ "symbol": "...DeleteRowActionType.undo", "calls": 2, "tests": 2 }],
|
|
66
|
+
"stand_ins": {},
|
|
67
|
+
"changed_sites": [{ "line": 3240, "predicate": "view is None", "true": 0, "false": 3 }]
|
|
68
|
+
}],
|
|
69
|
+
"edges": [{ "caller": {...}, "callee": {...}, "executions": 2, "tests": [...], "tests_total": 2 }],
|
|
70
|
+
"boundaries": [{ "kind": "external", "caller": "...", "target": "celery.canvas._chord" }],
|
|
71
|
+
"gaps": [
|
|
72
|
+
{ "kind": "function_not_executed", "symbol": "...TrashHandler.restore_item" },
|
|
73
|
+
{ "kind": "branch_outcome_not_observed", "line": 217, "predicate": "not fields", "outcome": "true" },
|
|
74
|
+
{ "kind": "stand_in_reached", "target": "...FormulaFieldType.run_periodic_update" }
|
|
75
|
+
],
|
|
76
|
+
"not_reported": ["values (only type shapes and opaque fingerprints are recorded)",
|
|
77
|
+
"except-handler coverage (handlers are not decision sites)", "per-line coverage"]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Every "not executed" is relative to `universe.test_scope`: the tests that were run. Locations
|
|
82
|
+
carry `origin` (`repo`, `test`, `external`) so a consumer can tell application frames from test
|
|
83
|
+
frames.
|
|
84
|
+
|
|
85
|
+
The artifact's other sections (`nodes`, `edges`, `executions`, `boundaries`, `facts`) describe
|
|
86
|
+
the observed behavioral neighborhood of the change; `report.md` and `behavioral-map.md` render
|
|
87
|
+
it for people.
|
|
88
|
+
|
|
89
|
+
## Consumers
|
|
90
|
+
|
|
91
|
+
[Sydes](https://pypi.org/project/sydes/) uses the runtime contract for change verification:
|
|
92
|
+
observed call edges join its call graph for reachability, the exact tests per changed function
|
|
93
|
+
become supporting test evidence, the gaps become verification gaps, and AI recovery is only asked
|
|
94
|
+
about what the runtime evidence cannot answer. Sydes depends on the contract alone, not on
|
|
95
|
+
diffgenome internals.
|
|
96
|
+
|
|
97
|
+
## Optional: the Behavioral Genome (research)
|
|
98
|
+
|
|
99
|
+
`diffgenome genome` builds a semantic layer on top of the runtime evidence: a model proposes
|
|
100
|
+
behavioral rules (variables, decisions, transitions), and a deterministic checker keeps only the
|
|
101
|
+
rules the observed executions verify or support. It is optional research code: nothing in
|
|
102
|
+
`diffgenome change` or the runtime contract uses it, and it needs no extra packages (an OpenAI
|
|
103
|
+
key only for live proposals, read from `OPENAI_API_KEY` or `~/.config/diffgenome/openai_api_key`).
|
|
104
|
+
Install with `pip install "diffgenome[genome]"` to state the intent. See
|
|
105
|
+
`docs/research-overview.md` and `docs/runtime-evaluation.md` for what has and has not been
|
|
106
|
+
shown to work.
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
uv sync
|
|
112
|
+
uv run pytest
|
|
113
|
+
uv run ruff check src tests && uv run mypy src
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# exp01_shop — fixture target repository
|
|
2
|
+
|
|
3
|
+
A deliberately small "repository under analysis" for [experiment 01](../../docs/experiment-01.md).
|
|
4
|
+
Its unit tests substitute internal dependencies at different layers so that no single test
|
|
5
|
+
observes the full path.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
OrderController.place_order
|
|
9
|
+
→ OrderService.place
|
|
10
|
+
→ _validate
|
|
11
|
+
→ InventoryService.reserve (real impl does HTTP; has NO unit test → coverage gap)
|
|
12
|
+
→ PricingService.quote
|
|
13
|
+
→ PriceRepository.price_for
|
|
14
|
+
→ sqlite3.Connection (external)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
| Test | Real code exercised | Stand-ins |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `test_controller.py::test_place_order_returns_quoted_total` | Controller, OrderService | `PricingService`, `InventoryService` (autospec: claim in repo → internal) |
|
|
20
|
+
| `test_pricing_service.py::test_quote_sums_repository_prices` | PricingService, PriceRepository | `sqlite3.Connection` (autospec: claim outside repo → external) |
|
|
21
|
+
| `test_pricing_service.py::test_quote_empty_cart_is_free` | PricingService (short-circuit) | `sqlite3.Connection` (never called) |
|
|
22
|
+
| `test_order_service.py::test_place_with_unspecced_mocks` | OrderService | claim-less `MagicMock`s → must stay **unresolved** |
|
|
23
|
+
| `test_order_service.py::test_duplicate_skus_rejected` | OrderService, `_validate` **raising** `ValueError` | autospec stand-ins (never reached) |
|
|
24
|
+
| `test_controller.py::test_place_order_with_order_service_stand_in` | Controller only | `OrderService` (autospec → internal; seed for the outcome-conflict and two-hop cases) |
|
|
25
|
+
|
|
26
|
+
The stand-ins here happen to be `unittest.mock` objects because the fixture is Python.
|
|
27
|
+
diffgenome's model sees them only as `SubstitutionNode`s with mechanism `MOCK_OBJECT`.
|
|
28
|
+
|
|
29
|
+
Run its own suite (must pass before tracing means anything):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
cd fixtures/exp01_shop && python -m pytest -q
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`groundtruth/` holds whole-stack executions used only as ground truth in experiment 05.
|
|
36
|
+
It is outside `testpaths` on purpose: those runs must never enter the corpus the composer
|
|
37
|
+
reconstructs from. Run them explicitly: `python -m pytest -q groundtruth`.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Whole-stack execution used only as GROUND TRUTH in experiment 05: never part of the
|
|
2
|
+
corpus the composer reconstructs from. Everything in the repository runs for real over an
|
|
3
|
+
in-memory sqlite database; the one true external (the inventory HTTP call) is substituted."""
|
|
4
|
+
|
|
5
|
+
import sqlite3
|
|
6
|
+
from unittest.mock import MagicMock, patch
|
|
7
|
+
|
|
8
|
+
from shop.controller import OrderController
|
|
9
|
+
from shop.inventory_service import InventoryService
|
|
10
|
+
from shop.order_service import OrderService
|
|
11
|
+
from shop.price_repository import PriceRepository
|
|
12
|
+
from shop.pricing_service import PricingService
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _stack() -> OrderController:
|
|
16
|
+
conn = sqlite3.connect(":memory:")
|
|
17
|
+
conn.execute("CREATE TABLE prices (sku TEXT PRIMARY KEY, cents INTEGER)")
|
|
18
|
+
conn.executemany("INSERT INTO prices VALUES (?, ?)", [("A", 1000), ("B", 1500)])
|
|
19
|
+
pricing = PricingService(PriceRepository(conn))
|
|
20
|
+
inventory = InventoryService("http://inventory.local")
|
|
21
|
+
return OrderController(OrderService(pricing, inventory))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_place_order_end_to_end() -> None:
|
|
25
|
+
response = MagicMock()
|
|
26
|
+
response.status = 201
|
|
27
|
+
context = MagicMock()
|
|
28
|
+
context.__enter__.return_value = response
|
|
29
|
+
with patch("urllib.request.urlopen", return_value=context):
|
|
30
|
+
result = _stack().place_order({"customer_id": "c-1", "skus": ["A", "B"]})
|
|
31
|
+
assert result == {"status": "accepted", "total_cents": 2500}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_duplicate_skus_end_to_end() -> None:
|
|
35
|
+
import pytest
|
|
36
|
+
|
|
37
|
+
with pytest.raises(ValueError):
|
|
38
|
+
_stack().place_order({"customer_id": "c-3", "skus": ["A", "A"]})
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from shop.order_service import OrderService
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class OrderController:
|
|
7
|
+
def __init__(self, orders: OrderService) -> None:
|
|
8
|
+
self._orders = orders
|
|
9
|
+
|
|
10
|
+
def place_order(self, request: dict[str, Any]) -> dict[str, Any]:
|
|
11
|
+
order = self._orders.place(request["customer_id"], list(request["skus"]))
|
|
12
|
+
return {"status": "accepted", "total_cents": order.total_cents}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import urllib.request
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class InventoryService:
|
|
6
|
+
"""Talks to a remote inventory API. Intentionally has no unit test of its own."""
|
|
7
|
+
|
|
8
|
+
def __init__(self, base_url: str) -> None:
|
|
9
|
+
self._base_url = base_url
|
|
10
|
+
|
|
11
|
+
def reserve(self, skus: list[str]) -> None:
|
|
12
|
+
body = json.dumps({"skus": skus}).encode()
|
|
13
|
+
request = urllib.request.Request(f"{self._base_url}/reservations", data=body, method="POST")
|
|
14
|
+
with urllib.request.urlopen(request, timeout=5) as response:
|
|
15
|
+
if response.status != 201:
|
|
16
|
+
raise RuntimeError(f"reservation failed: {response.status}")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from shop.inventory_service import InventoryService
|
|
4
|
+
from shop.pricing_service import PricingService
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(frozen=True)
|
|
8
|
+
class Order:
|
|
9
|
+
customer_id: str
|
|
10
|
+
skus: tuple[str, ...]
|
|
11
|
+
total_cents: int
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _validate(skus: list[str]) -> None:
|
|
15
|
+
if len(set(skus)) != len(skus):
|
|
16
|
+
raise ValueError("duplicate sku in order")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class OrderService:
|
|
20
|
+
def __init__(self, pricing: PricingService, inventory: InventoryService) -> None:
|
|
21
|
+
self._pricing = pricing
|
|
22
|
+
self._inventory = inventory
|
|
23
|
+
|
|
24
|
+
def place(self, customer_id: str, skus: list[str]) -> Order:
|
|
25
|
+
_validate(skus)
|
|
26
|
+
self._inventory.reserve(skus)
|
|
27
|
+
total = self._pricing.quote(skus)
|
|
28
|
+
return Order(customer_id, tuple(skus), total)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import sqlite3
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class PriceRepository:
|
|
5
|
+
def __init__(self, conn: sqlite3.Connection) -> None:
|
|
6
|
+
self._conn = conn
|
|
7
|
+
|
|
8
|
+
def price_for(self, sku: str) -> int:
|
|
9
|
+
row = self._conn.execute("SELECT cents FROM prices WHERE sku = ?", (sku,)).fetchone()
|
|
10
|
+
if row is None:
|
|
11
|
+
raise KeyError(sku)
|
|
12
|
+
return int(row[0])
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from shop.price_repository import PriceRepository
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class PricingService:
|
|
5
|
+
def __init__(self, prices: PriceRepository) -> None:
|
|
6
|
+
self._prices = prices
|
|
7
|
+
|
|
8
|
+
def quote(self, skus: list[str]) -> int:
|
|
9
|
+
if not skus:
|
|
10
|
+
return 0
|
|
11
|
+
total = 0
|
|
12
|
+
for sku in skus: # explicit loop: experiment 01 does not handle generator frames
|
|
13
|
+
total += self._prices.price_for(sku)
|
|
14
|
+
return total
|