vraven 0.9.0a1__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 (214) hide show
  1. vraven-0.9.0a1/LICENSE +201 -0
  2. vraven-0.9.0a1/NOTICE +5 -0
  3. vraven-0.9.0a1/PKG-INFO +453 -0
  4. vraven-0.9.0a1/README.md +403 -0
  5. vraven-0.9.0a1/pyproject.toml +91 -0
  6. vraven-0.9.0a1/setup.cfg +4 -0
  7. vraven-0.9.0a1/src/vraven/__init__.py +86 -0
  8. vraven-0.9.0a1/src/vraven/adapters/__init__.py +13 -0
  9. vraven-0.9.0a1/src/vraven/adapters/base.py +18 -0
  10. vraven-0.9.0a1/src/vraven/adapters/pytorch.py +288 -0
  11. vraven-0.9.0a1/src/vraven/adapters/pytorch_loader.py +131 -0
  12. vraven-0.9.0a1/src/vraven/adapters/registry.py +27 -0
  13. vraven-0.9.0a1/src/vraven/analysis/__init__.py +16 -0
  14. vraven-0.9.0a1/src/vraven/analysis/comparison.py +136 -0
  15. vraven-0.9.0a1/src/vraven/analysis/dataset.py +506 -0
  16. vraven-0.9.0a1/src/vraven/analysis/evolution.py +128 -0
  17. vraven-0.9.0a1/src/vraven/attribution/__init__.py +5 -0
  18. vraven-0.9.0a1/src/vraven/attribution/lrp.py +277 -0
  19. vraven-0.9.0a1/src/vraven/attribution/rules.py +71 -0
  20. vraven-0.9.0a1/src/vraven/capture/__init__.py +21 -0
  21. vraven-0.9.0a1/src/vraven/capture/pytorch_hooks.py +202 -0
  22. vraven-0.9.0a1/src/vraven/capture/selectors.py +62 -0
  23. vraven-0.9.0a1/src/vraven/capture/tensor_utils.py +155 -0
  24. vraven-0.9.0a1/src/vraven/causal/__init__.py +17 -0
  25. vraven-0.9.0a1/src/vraven/causal/counterfactual.py +154 -0
  26. vraven-0.9.0a1/src/vraven/causal/interventions.py +71 -0
  27. vraven-0.9.0a1/src/vraven/causal/perturbation.py +157 -0
  28. vraven-0.9.0a1/src/vraven/causal/validation.py +133 -0
  29. vraven-0.9.0a1/src/vraven/cli.py +397 -0
  30. vraven-0.9.0a1/src/vraven/core/__init__.py +38 -0
  31. vraven-0.9.0a1/src/vraven/core/config.py +83 -0
  32. vraven-0.9.0a1/src/vraven/core/device.py +135 -0
  33. vraven-0.9.0a1/src/vraven/core/errors.py +35 -0
  34. vraven-0.9.0a1/src/vraven/core/explainer.py +83 -0
  35. vraven-0.9.0a1/src/vraven/core/metadata.py +86 -0
  36. vraven-0.9.0a1/src/vraven/core/output.py +227 -0
  37. vraven-0.9.0a1/src/vraven/core/trace.py +266 -0
  38. vraven-0.9.0a1/src/vraven/core/tree.py +67 -0
  39. vraven-0.9.0a1/src/vraven/darkside/__init__.py +73 -0
  40. vraven-0.9.0a1/src/vraven/darkside/adversarial.py +95 -0
  41. vraven-0.9.0a1/src/vraven/darkside/anatomy.py +206 -0
  42. vraven-0.9.0a1/src/vraven/darkside/capacity.py +101 -0
  43. vraven-0.9.0a1/src/vraven/darkside/circuit_multiplicity.py +202 -0
  44. vraven-0.9.0a1/src/vraven/darkside/class_conditional.py +194 -0
  45. vraven-0.9.0a1/src/vraven/darkside/contracts.py +149 -0
  46. vraven-0.9.0a1/src/vraven/darkside/cost_evidence.py +95 -0
  47. vraven-0.9.0a1/src/vraven/darkside/dataset.py +268 -0
  48. vraven-0.9.0a1/src/vraven/darkside/decision_circuitry.py +239 -0
  49. vraven-0.9.0a1/src/vraven/darkside/disagreement.py +124 -0
  50. vraven-0.9.0a1/src/vraven/darkside/edge_cards.py +740 -0
  51. vraven-0.9.0a1/src/vraven/darkside/explanation_uncertainty.py +92 -0
  52. vraven-0.9.0a1/src/vraven/darkside/failure_anatomy.py +103 -0
  53. vraven-0.9.0a1/src/vraven/darkside/interventions.py +222 -0
  54. vraven-0.9.0a1/src/vraven/darkside/math_utils.py +412 -0
  55. vraven-0.9.0a1/src/vraven/darkside/mechanism_transfer.py +84 -0
  56. vraven-0.9.0a1/src/vraven/darkside/mediation.py +109 -0
  57. vraven-0.9.0a1/src/vraven/darkside/ood.py +140 -0
  58. vraven-0.9.0a1/src/vraven/darkside/registry.py +161 -0
  59. vraven-0.9.0a1/src/vraven/darkside/representation_drift.py +99 -0
  60. vraven-0.9.0a1/src/vraven/darkside/serialisation.py +25 -0
  61. vraven-0.9.0a1/src/vraven/darkside/session.py +130 -0
  62. vraven-0.9.0a1/src/vraven/darkside/shortcut.py +362 -0
  63. vraven-0.9.0a1/src/vraven/darkside/stability_geometry.py +88 -0
  64. vraven-0.9.0a1/src/vraven/darkside/synergy.py +109 -0
  65. vraven-0.9.0a1/src/vraven/darkside/topology.py +130 -0
  66. vraven-0.9.0a1/src/vraven/darkside/visualisation/__init__.py +5 -0
  67. vraven-0.9.0a1/src/vraven/darkside/visualisation/figures.py +705 -0
  68. vraven-0.9.0a1/src/vraven/darkside/wiring.py +192 -0
  69. vraven-0.9.0a1/src/vraven/decompiler/__init__.py +220 -0
  70. vraven-0.9.0a1/src/vraven/decompiler/adversarial.py +2669 -0
  71. vraven-0.9.0a1/src/vraven/decompiler/adversarial_evidence.py +667 -0
  72. vraven-0.9.0a1/src/vraven/decompiler/adversarial_mechanism.py +555 -0
  73. vraven-0.9.0a1/src/vraven/decompiler/capture.py +1285 -0
  74. vraven-0.9.0a1/src/vraven/decompiler/causal_graph.py +576 -0
  75. vraven-0.9.0a1/src/vraven/decompiler/certificate.py +427 -0
  76. vraven-0.9.0a1/src/vraven/decompiler/concepts.py +852 -0
  77. vraven-0.9.0a1/src/vraven/decompiler/contrastive.py +256 -0
  78. vraven-0.9.0a1/src/vraven/decompiler/counterfactual.py +598 -0
  79. vraven-0.9.0a1/src/vraven/decompiler/data/__init__.py +1 -0
  80. vraven-0.9.0a1/src/vraven/decompiler/data/operator_semantics.json +539 -0
  81. vraven-0.9.0a1/src/vraven/decompiler/decompilebench.py +199 -0
  82. vraven-0.9.0a1/src/vraven/decompiler/decompiler.py +542 -0
  83. vraven-0.9.0a1/src/vraven/decompiler/drift.py +57 -0
  84. vraven-0.9.0a1/src/vraven/decompiler/evolution.py +305 -0
  85. vraven-0.9.0a1/src/vraven/decompiler/feature_audit.py +417 -0
  86. vraven-0.9.0a1/src/vraven/decompiler/formal_mechanism.py +2000 -0
  87. vraven-0.9.0a1/src/vraven/decompiler/formal_robustness.py +1868 -0
  88. vraven-0.9.0a1/src/vraven/decompiler/interventions.py +377 -0
  89. vraven-0.9.0a1/src/vraven/decompiler/ir.py +396 -0
  90. vraven-0.9.0a1/src/vraven/decompiler/patching.py +62 -0
  91. vraven-0.9.0a1/src/vraven/decompiler/profiler.py +210 -0
  92. vraven-0.9.0a1/src/vraven/decompiler/programme.py +722 -0
  93. vraven-0.9.0a1/src/vraven/decompiler/report.py +376 -0
  94. vraven-0.9.0a1/src/vraven/decompiler/runtime.py +318 -0
  95. vraven-0.9.0a1/src/vraven/decompiler/semantics.py +155 -0
  96. vraven-0.9.0a1/src/vraven/decompiler/verification_protocol.py +212 -0
  97. vraven-0.9.0a1/src/vraven/decompiler/visuals/__init__.py +53 -0
  98. vraven-0.9.0a1/src/vraven/decompiler/visuals/causal_proof.py +244 -0
  99. vraven-0.9.0a1/src/vraven/decompiler/visuals/common.py +131 -0
  100. vraven-0.9.0a1/src/vraven/decompiler/visuals/concept_genome.py +216 -0
  101. vraven-0.9.0a1/src/vraven/decompiler/visuals/contrastive_proof.py +266 -0
  102. vraven-0.9.0a1/src/vraven/decompiler/visuals/counterfactual_twin.py +364 -0
  103. vraven-0.9.0a1/src/vraven/decompiler/visuals/dark_matter.py +215 -0
  104. vraven-0.9.0a1/src/vraven/decompiler/visuals/model_xray.py +255 -0
  105. vraven-0.9.0a1/src/vraven/decompiler/visuals/programme_proof.py +275 -0
  106. vraven-0.9.0a1/src/vraven/figures/__init__.py +6 -0
  107. vraven-0.9.0a1/src/vraven/figures/__main__.py +3 -0
  108. vraven-0.9.0a1/src/vraven/figures/architecture.py +313 -0
  109. vraven-0.9.0a1/src/vraven/figures/integration.py +132 -0
  110. vraven-0.9.0a1/src/vraven/figures/methodology.py +415 -0
  111. vraven-0.9.0a1/src/vraven/figures/primitives.py +466 -0
  112. vraven-0.9.0a1/src/vraven/figures/registry.py +151 -0
  113. vraven-0.9.0a1/src/vraven/figures/render.py +106 -0
  114. vraven-0.9.0a1/src/vraven/figures/theme.py +78 -0
  115. vraven-0.9.0a1/src/vraven/figures/validation.py +257 -0
  116. vraven-0.9.0a1/src/vraven/metrics/__init__.py +56 -0
  117. vraven-0.9.0a1/src/vraven/metrics/agreement.py +97 -0
  118. vraven-0.9.0a1/src/vraven/metrics/basic.py +158 -0
  119. vraven-0.9.0a1/src/vraven/metrics/evidence_audit.py +343 -0
  120. vraven-0.9.0a1/src/vraven/metrics/influence.py +80 -0
  121. vraven-0.9.0a1/src/vraven/metrics/stability.py +39 -0
  122. vraven-0.9.0a1/src/vraven/metrics/uncertainty.py +67 -0
  123. vraven-0.9.0a1/src/vraven/py.typed +1 -0
  124. vraven-0.9.0a1/src/vraven/reasoning/__init__.py +38 -0
  125. vraven-0.9.0a1/src/vraven/reasoning/communities.py +91 -0
  126. vraven-0.9.0a1/src/vraven/reasoning/fingerprint.py +117 -0
  127. vraven-0.9.0a1/src/vraven/reasoning/graph.py +44 -0
  128. vraven-0.9.0a1/src/vraven/reasoning/pathways.py +64 -0
  129. vraven-0.9.0a1/src/vraven/reasoning/projection.py +354 -0
  130. vraven-0.9.0a1/src/vraven/report/__init__.py +11 -0
  131. vraven-0.9.0a1/src/vraven/report/html.py +1128 -0
  132. vraven-0.9.0a1/src/vraven/report/report.py +572 -0
  133. vraven-0.9.0a1/src/vraven/visualisation/__init__.py +78 -0
  134. vraven-0.9.0a1/src/vraven/visualisation/attention.py +118 -0
  135. vraven-0.9.0a1/src/vraven/visualisation/base.py +139 -0
  136. vraven-0.9.0a1/src/vraven/visualisation/causal_pathway.py +123 -0
  137. vraven-0.9.0a1/src/vraven/visualisation/community_graph.py +274 -0
  138. vraven-0.9.0a1/src/vraven/visualisation/conflict_field.py +146 -0
  139. vraven-0.9.0a1/src/vraven/visualisation/consistency.py +111 -0
  140. vraven-0.9.0a1/src/vraven/visualisation/counterfactual_delta.py +215 -0
  141. vraven-0.9.0a1/src/vraven/visualisation/decision_flow.py +158 -0
  142. vraven-0.9.0a1/src/vraven/visualisation/decision_sankey.py +448 -0
  143. vraven-0.9.0a1/src/vraven/visualisation/energy.py +100 -0
  144. vraven-0.9.0a1/src/vraven/visualisation/evidence_trajectory.py +240 -0
  145. vraven-0.9.0a1/src/vraven/visualisation/export.py +74 -0
  146. vraven-0.9.0a1/src/vraven/visualisation/feature_sequence_heatmap.py +150 -0
  147. vraven-0.9.0a1/src/vraven/visualisation/input_attribution.py +248 -0
  148. vraven-0.9.0a1/src/vraven/visualisation/labels.py +106 -0
  149. vraven-0.9.0a1/src/vraven/visualisation/latent_flight.py +243 -0
  150. vraven-0.9.0a1/src/vraven/visualisation/mechanism_concordance.py +208 -0
  151. vraven-0.9.0a1/src/vraven/visualisation/model_comparison.py +138 -0
  152. vraven-0.9.0a1/src/vraven/visualisation/model_evolution.py +174 -0
  153. vraven-0.9.0a1/src/vraven/visualisation/neuron_impact.py +162 -0
  154. vraven-0.9.0a1/src/vraven/visualisation/neuron_importance.py +207 -0
  155. vraven-0.9.0a1/src/vraven/visualisation/palette.py +198 -0
  156. vraven-0.9.0a1/src/vraven/visualisation/perturbation_stability.py +161 -0
  157. vraven-0.9.0a1/src/vraven/visualisation/reasoning_dataset.py +349 -0
  158. vraven-0.9.0a1/src/vraven/visualisation/reasoning_dna.py +192 -0
  159. vraven-0.9.0a1/src/vraven/visualisation/reasoning_graph.py +155 -0
  160. vraven-0.9.0a1/src/vraven/visualisation/relevance_flow.py +174 -0
  161. vraven-0.9.0a1/src/vraven/visualisation/scichart_export.py +743 -0
  162. vraven-0.9.0a1/src/vraven/visualisation/spectral_trace.py +107 -0
  163. vraven-0.9.0a1/src/vraven/visualisation/theme.py +363 -0
  164. vraven-0.9.0a1/src/vraven.egg-info/PKG-INFO +453 -0
  165. vraven-0.9.0a1/src/vraven.egg-info/SOURCES.txt +212 -0
  166. vraven-0.9.0a1/src/vraven.egg-info/dependency_links.txt +1 -0
  167. vraven-0.9.0a1/src/vraven.egg-info/entry_points.txt +2 -0
  168. vraven-0.9.0a1/src/vraven.egg-info/requires.txt +33 -0
  169. vraven-0.9.0a1/src/vraven.egg-info/top_level.txt +1 -0
  170. vraven-0.9.0a1/tests/test_agreement_metrics.py +19 -0
  171. vraven-0.9.0a1/tests/test_attention_capture.py +37 -0
  172. vraven-0.9.0a1/tests/test_basic_metrics.py +11 -0
  173. vraven-0.9.0a1/tests/test_causal_mode.py +27 -0
  174. vraven-0.9.0a1/tests/test_cli.py +13 -0
  175. vraven-0.9.0a1/tests/test_code_inventory.py +47 -0
  176. vraven-0.9.0a1/tests/test_community_graph.py +35 -0
  177. vraven-0.9.0a1/tests/test_counterfactual.py +25 -0
  178. vraven-0.9.0a1/tests/test_darkside_advanced.py +54 -0
  179. vraven-0.9.0a1/tests/test_darkside_all_visuals.py +194 -0
  180. vraven-0.9.0a1/tests/test_darkside_anatomy_wiring.py +91 -0
  181. vraven-0.9.0a1/tests/test_darkside_circuit_multiplicity.py +61 -0
  182. vraven-0.9.0a1/tests/test_darkside_cohorts.py +75 -0
  183. vraven-0.9.0a1/tests/test_darkside_dataset.py +85 -0
  184. vraven-0.9.0a1/tests/test_darkside_live.py +89 -0
  185. vraven-0.9.0a1/tests/test_darkside_math.py +61 -0
  186. vraven-0.9.0a1/tests/test_darkside_registry_serialisation.py +29 -0
  187. vraven-0.9.0a1/tests/test_darkside_safeguards.py +111 -0
  188. vraven-0.9.0a1/tests/test_darkside_visuals.py +73 -0
  189. vraven-0.9.0a1/tests/test_dataset_analysis.py +85 -0
  190. vraven-0.9.0a1/tests/test_decompiler_adversarial.py +556 -0
  191. vraven-0.9.0a1/tests/test_evidence_audit.py +135 -0
  192. vraven-0.9.0a1/tests/test_explainer.py +16 -0
  193. vraven-0.9.0a1/tests/test_figures.py +29 -0
  194. vraven-0.9.0a1/tests/test_formal_mechanism.py +862 -0
  195. vraven-0.9.0a1/tests/test_formal_robustness.py +265 -0
  196. vraven-0.9.0a1/tests/test_full_tensor_capture.py +31 -0
  197. vraven-0.9.0a1/tests/test_gradient_capture.py +42 -0
  198. vraven-0.9.0a1/tests/test_html_theme_toggle.py +66 -0
  199. vraven-0.9.0a1/tests/test_lrp_and_mockup_suite.py +117 -0
  200. vraven-0.9.0a1/tests/test_model_comparison.py +72 -0
  201. vraven-0.9.0a1/tests/test_model_evolution.py +45 -0
  202. vraven-0.9.0a1/tests/test_model_loading.py +84 -0
  203. vraven-0.9.0a1/tests/test_optional_devices.py +26 -0
  204. vraven-0.9.0a1/tests/test_public_api.py +22 -0
  205. vraven-0.9.0a1/tests/test_publication_evidence.py +72 -0
  206. vraven-0.9.0a1/tests/test_publication_model_suite.py +126 -0
  207. vraven-0.9.0a1/tests/test_publication_presets.py +9 -0
  208. vraven-0.9.0a1/tests/test_reasoning_and_visuals.py +59 -0
  209. vraven-0.9.0a1/tests/test_release_script.py +27 -0
  210. vraven-0.9.0a1/tests/test_reproducibility_metadata.py +18 -0
  211. vraven-0.9.0a1/tests/test_source_completeness.py +29 -0
  212. vraven-0.9.0a1/tests/test_standalone_visualisation.py +50 -0
  213. vraven-0.9.0a1/tests/test_trace_serialisation.py +16 -0
  214. vraven-0.9.0a1/tests/test_visual_themes.py +63 -0
vraven-0.9.0a1/LICENSE ADDED
@@ -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 authorised 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 authorised 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. (Do not 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 2026 Daniel Jeremiah and VRAVEN contributors
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.
vraven-0.9.0a1/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ VRAVEN
2
+ Copyright 2026 Daniel Jeremiah and VRAVEN contributors.
3
+
4
+ VRAVEN stands for Visual Reasoning and Activation Visualisation for Explainable Networks.
5
+ The project includes original source code, documentation and scientific visual contracts.
@@ -0,0 +1,453 @@
1
+ Metadata-Version: 2.4
2
+ Name: vraven
3
+ Version: 0.9.0a1
4
+ Summary: Compiler-assisted causal decompilation and scientific visual explanation of PyTorch models
5
+ Author: Daniel Jeremiah and VRAVEN contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/vraven-ai/vraven
8
+ Project-URL: Repository, https://github.com/vraven-ai/vraven
9
+ Project-URL: Issues, https://github.com/vraven-ai/vraven/issues
10
+ Keywords: explainable-ai,deep-learning,pytorch,mechanistic-interpretability,causal-decompilation,visualisation
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Requires-Dist: numpy>=1.26
24
+ Requires-Dist: torch>=2.2
25
+ Requires-Dist: plotly>=6.1
26
+ Requires-Dist: networkx>=3.2
27
+ Provides-Extra: publication
28
+ Requires-Dist: kaleido>=1.0; extra == "publication"
29
+ Provides-Extra: sklearn
30
+ Requires-Dist: scikit-learn>=1.4; extra == "sklearn"
31
+ Provides-Extra: analysis
32
+ Requires-Dist: scipy>=1.11; extra == "analysis"
33
+ Requires-Dist: scikit-learn>=1.4; extra == "analysis"
34
+ Provides-Extra: darkside
35
+ Requires-Dist: scipy>=1.11; extra == "darkside"
36
+ Requires-Dist: scikit-learn>=1.4; extra == "darkside"
37
+ Requires-Dist: ripser>=0.6.8; extra == "darkside"
38
+ Provides-Extra: dev
39
+ Requires-Dist: build>=1.2; extra == "dev"
40
+ Requires-Dist: pandas>=2.0; extra == "dev"
41
+ Requires-Dist: pytest>=8.0; extra == "dev"
42
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
43
+ Requires-Dist: ruff>=0.9; extra == "dev"
44
+ Requires-Dist: mypy>=1.13; extra == "dev"
45
+ Requires-Dist: scikit-learn>=1.4; extra == "dev"
46
+ Requires-Dist: scipy>=1.11; extra == "dev"
47
+ Requires-Dist: svgwrite>=1.4; extra == "dev"
48
+ Requires-Dist: tomli>=2.0; python_version < "3.11" and extra == "dev"
49
+ Dynamic: license-file
50
+
51
+ # VRAVEN
52
+
53
+ <p align="center">
54
+ <img src="assets/branding/avatars/vraven-avatar-256.png" alt="VRAVEN raven signature" width="220">
55
+ </p>
56
+
57
+ **Visual Reasoning and Activation Visualisation for Explainable Networks**
58
+
59
+ ## Compiler-assisted causal decompilation of PyTorch models
60
+
61
+ VRAVEN is an experimental framework for reverse engineering a trained PyTorch model into a compact, executable and experimentally tested high-level decision mechanism.
62
+
63
+ It addresses a different question from ordinary feature attribution:
64
+
65
+ ```text
66
+ SHAP / LIME:
67
+ Which input variables influenced the prediction?
68
+
69
+ VRAVEN:
70
+ What computation was recovered, what internal concepts appeared, how did they interact,
71
+ which relationships survived intervention, can the mechanism execute as a compact programme,
72
+ what would change the decision, and what remains unexplained?
73
+ ```
74
+
75
+ The central pipeline is:
76
+
77
+ ```text
78
+ Trained Model
79
+ ↓
80
+ Internal Concept Discovery
81
+ ↓
82
+ Concept Evolution
83
+ ↓
84
+ Causal Mechanism Graph
85
+ ↓
86
+ Executable Decision Programme
87
+ ↓
88
+ Contrastive Explanation
89
+ ↓
90
+ Counterfactual Proof
91
+ ↓
92
+ Validity and Coverage Certificate
93
+ ```
94
+
95
+ VRAVEN does **not** claim to recover one uniquely true explanation of every model. It recovers the smallest tested high-level programme found under the configured search and reports a validity envelope, fidelity evidence and unresolved model dark matter.
96
+
97
+ ## What is implemented in 0.9.0a1
98
+
99
+ ### Multi-route model capture
100
+
101
+ VRAVEN attempts:
102
+
103
+ 1. `torch.export`
104
+ 2. `torch.fx`
105
+ 3. Runtime operator dispatch
106
+ 4. Module-hook fallback
107
+
108
+ The preferred route produces a normalised ATen-level graph. Failed attempts and fallback limitations are retained in the certificate.
109
+
110
+ ### VRAVEN Mechanism IR
111
+
112
+ The architecture-neutral intermediate representation records:
113
+
114
+ * Operators, parameters and buffers
115
+ * Tensor-flow edges
116
+ * Shapes, data types, devices and strides
117
+ * Dynamic-shape constraints and guards
118
+ * Source and module provenance
119
+ * Operator semantics
120
+ * Autograd-path availability
121
+ * Graph intervention points
122
+ * Numerical equivalence
123
+ * Unsupported computation
124
+
125
+ ### Automatic internal concept discovery
126
+
127
+ VRAVEN currently supports:
128
+
129
+ * Deterministic PCA concepts
130
+ * Sparse-autoencoder concepts
131
+ * Class preference and effect size
132
+ * Top activating samples
133
+ * Conservative association with supplied domain feature groups
134
+ * Explicit unresolved concepts where meaning is not established
135
+
136
+ ### Cross-layer concept evolution
137
+
138
+ A regularised optimal-transport alignment represents concept birth, persistence, splitting, merging and termination without treating independent embeddings as literal movement.
139
+
140
+ ### Graph-compiled causal interventions
141
+
142
+ VRAVEN rewrites the captured FX or Export graph and inserts explicit intervention modules. Supported interventions include:
143
+
144
+ ```text
145
+ zero
146
+ replace
147
+ scale
148
+ add
149
+ erase_direction
150
+ set_concept
151
+ set_concept_mean
152
+ clamp
153
+ ```
154
+
155
+ Effects are measured using a target-versus-alternatives logit margin and reported with bootstrap intervals, sign stability and prediction flips.
156
+
157
+ ### Intervention-constrained executable programme
158
+
159
+ The programme is fitted jointly against:
160
+
161
+ * Normal target margins
162
+ * Tested internal intervention effects
163
+
164
+ This is important because a conventional observational surrogate can achieve very high predictive fit while failing to reproduce the model under intervention.
165
+
166
+ VRAVEN reports:
167
+
168
+ ```text
169
+ observational validation R²
170
+ observational decision agreement
171
+ interventional correlation
172
+ interventional mean absolute error
173
+ interventional sign agreement
174
+ counterfactual programme and model agreement
175
+ ```
176
+
177
+ No opaque combined trust score is emitted.
178
+
179
+ ### Contrastive and counterfactual explanation
180
+
181
+ VRAVEN explains why the selected class was preferred over its strongest alternative and can search for bounded concept-level counterfactuals. Candidates are verified by executing graph-compiled interventions in the original captured model.
182
+
183
+ Internal counterfactual validity and domain validity are reported separately.
184
+
185
+ ### Explanation certificate
186
+
187
+ Every result includes:
188
+
189
+ * Validity envelope
190
+ * Operator coverage
191
+ * Parameter coverage
192
+ * Gradient coverage
193
+ * Intervention coverage
194
+ * Validated semantic coverage
195
+ * Association-only semantic coverage
196
+ * Causally weighted unresolved responsibility
197
+ * Observational fidelity
198
+ * Interventional fidelity
199
+ * Counterfactual evidence
200
+ * Claim lattice
201
+ * Known limitations
202
+
203
+ ## Signature scientific visualisations
204
+
205
+ Each figure is standalone and supports the same scientific values in two modes:
206
+
207
+ ```text
208
+ interactive_dark
209
+ publication_light
210
+ ```
211
+
212
+ | VRAVEN visual | Scientific object |
213
+ |---|---|
214
+ | **Raven Eye** | Full-stack model X-ray and capture coverage |
215
+ | **Raven Flight** | Cross-layer concept genome |
216
+ | **Raven Brain** | Bidirectional causal proof graph |
217
+ | **Raven Code** | Executable programme proof tree |
218
+ | **Raven Contrast** | Why the selected class defeated its alternative |
219
+ | **Raven Shadow** | Original versus counterfactual mechanism |
220
+ | **Raven Dark Matter** | Explained, associated, intervention-inaccessible and unresolved computation |
221
+
222
+ The figures are not generic dashboards. Every node, edge, width, colour and pattern has a declared scientific meaning stored in Plotly metadata.
223
+
224
+ ### Trace-level Scientific Evidence Audit
225
+
226
+ The standard `vraven.explain(..., mode="causal")` report now tests whether local
227
+ activation–gradient rankings agree with measured zero-output ablations. It exposes evidence
228
+ entropy, effective layer count, participation ratio, Gini concentration, signed cancellation,
229
+ causal coverage, rank/sign/cosine concordance, L1 discrepancy and permutation significance as
230
+ separate quantities. HTML reports lead with critical findings and a complete layer evidence
231
+ ledger; no composite trust score is emitted.
232
+
233
+ ```python
234
+ report = vraven.explain(model, inputs, target=1, mode="causal")
235
+ audit = report.scientific_audit()
236
+ report.mechanism_concordance(mode="publication_light")
237
+ report.export_html("vraven_report.html")
238
+ ```
239
+
240
+ Definitions, assumptions and validation limits are in `docs/EVIDENCE_AUDIT.md`.
241
+
242
+ ### Run every applicable analysis from one self-describing artefact
243
+
244
+ When a model bundle contains `model.pt`, `meta.json`, `reference.npz` and optional ordered
245
+ checkpoints, the complete research suite can be launched with the artefact directory as its
246
+ only argument:
247
+
248
+ ```bash
249
+ python scripts/run_vraven_artifact.py Models/image_pattern_cnn2d
250
+ ```
251
+
252
+ The runner reconstructs the declared architecture with safe state-dictionary loading, records
253
+ SHA-256 provenance, executes capture, decompilation, adversarial stress, Proof, Atlas, Watch,
254
+ Compare and every scientifically applicable DarkSide analysis, then writes an indexed HTML
255
+ gallery under `vraven_outputs/artifact_runs/`. Non-estimable analyses are recorded with their
256
+ missing evidence contract; they are never replaced with synthetic results.
257
+
258
+ ## Installation
259
+
260
+ ### Editable development installation
261
+
262
+ ```bash
263
+ python -m pip install -e ".[analysis,publication,dev]"
264
+ vraven doctor
265
+ ```
266
+
267
+ ### Local wheel
268
+
269
+ Build and validate the wheel:
270
+
271
+ ```bash
272
+ bash scripts/build_package.sh
273
+ python -m pip install dist/vraven-0.9.0a1-py3-none-any.whl
274
+ ```
275
+
276
+ To publish later, install the standard `build` and `twine` tools, build both wheel and source distribution, test with TestPyPI, and only then upload the reviewed release to public PyPI. See `docs/PYPI_RELEASE_GUIDE.md`.
277
+
278
+ This repository has not been published to the public PyPI index.
279
+
280
+ ## Quick Python example
281
+
282
+ ```python
283
+ import torch
284
+ import vraven
285
+
286
+ model = YourModel().eval()
287
+ reference = torch.load("reference_inputs.pt", weights_only=True)
288
+
289
+ config = vraven.DecompileConfig.quick()
290
+
291
+ result = vraven.reverse(
292
+ model,
293
+ (reference,),
294
+ focus_args=(reference[:1],),
295
+ target=1,
296
+ class_names={0: "Benign", 1: "Malware"},
297
+ config=config,
298
+ )
299
+
300
+ print(result.summary())
301
+
302
+ result.save("vraven_decision_proof")
303
+ result.write_report(
304
+ "vraven_decision_proof/report.html",
305
+ initial_mode="interactive_dark",
306
+ )
307
+
308
+ result.figure(
309
+ "causal_proof",
310
+ mode="publication_light",
311
+ ).write_html("causal_proof.html")
312
+ ```
313
+
314
+ ## Command line
315
+
316
+ ### Verify the environment
317
+
318
+ ```bash
319
+ vraven doctor
320
+ ```
321
+
322
+ ### Capture an unknown state-dictionary model into Mechanism IR
323
+
324
+ ```bash
325
+ vraven capture model.pt \
326
+ --model-factory my_project.models:Classifier \
327
+ --factory-kwargs '{"input_dim":476,"num_classes":2}' \
328
+ --input sample.npy \
329
+ --output mechanism_ir.json
330
+ ```
331
+
332
+ ### Run full decompilation
333
+
334
+ ```bash
335
+ vraven reverse model.pt \
336
+ --model-factory my_project.models:Classifier \
337
+ --factory-kwargs '{"input_dim":476,"num_classes":2}' \
338
+ --reference reference.npy \
339
+ --labels labels.npy \
340
+ --target 1 \
341
+ --class-names Benign,Malware \
342
+ --input-groups feature_groups.json \
343
+ --profile standard \
344
+ --output-dir vraven_decision_proof
345
+ ```
346
+
347
+ A `.pt` state dictionary contains weights, not an arbitrary architecture. A model factory is therefore required.
348
+
349
+ ### Run the planted-mechanism demonstration
350
+
351
+ ```bash
352
+ vraven decompile-demo \
353
+ --profile quick \
354
+ --output-dir vraven_decompile_demo
355
+ ```
356
+
357
+ ## Profiles
358
+
359
+ ### Quick
360
+
361
+ Designed for development and smoke testing. It uses deterministic PCA, bounded concept counts and smaller bootstrap budgets.
362
+
363
+ ### Standard
364
+
365
+ Uses the default research configuration.
366
+
367
+ ### Publication
368
+
369
+ Uses wider concept and causal searches, larger bootstrap budgets and more profiling repetitions. Publication profile does not make the result publication-ready by itself. Replication and matched baselines remain necessary.
370
+
371
+ ## Saved output structure
372
+
373
+ ```text
374
+ vraven_decision_proof/
375
+ ├── mechanism_ir.json
376
+ ├── concept_atlas/
377
+ ├── concept_evolution.json
378
+ ├── causal_mechanism_graph.json
379
+ ├── executable_programme.json
380
+ ├── executable_programme.txt
381
+ ├── contrastive_explanation.json
382
+ ├── counterfactual_proof.json
383
+ ├── mechanism_certificate.json
384
+ ├── mechanism_profile.json
385
+ ├── decompilation_manifest.json
386
+ └── report.html
387
+ ```
388
+
389
+ ## Known-mechanism benchmark
390
+
391
+ The repository includes `VRAVEN-DecompileBench`, a small PyTorch-native development benchmark with planted causal concepts, distractors, inhibitory signals and redundant pathways.
392
+
393
+ ```bash
394
+ python benchmarks/decompilebench.py \
395
+ --model planted_concept_mlp \
396
+ --samples 96 \
397
+ --output vraven_decompilebench
398
+ ```
399
+
400
+ It is a development benchmark, not yet a complete community benchmark.
401
+
402
+
403
+ ## Research and PyTorch source basis
404
+
405
+ The compiler design and research gap are documented in:
406
+
407
+ ```text
408
+ docs/decompiler/PYTORCH_2_13_SOURCE_INDEX.md
409
+ docs/decompiler/RESEARCH_SOURCE_INDEX.md
410
+ docs/decompiler/IMPLEMENTATION_GAP_CLOSURE.md
411
+ docs/decompiler/RESEARCH_POSITIONING.md
412
+ REFERENCES.bib
413
+ ```
414
+
415
+ The package records primary sources and open-access links rather than redistributing copyrighted books or publisher-controlled papers.
416
+
417
+ ## Scientific boundaries
418
+
419
+ VRAVEN currently does not establish that:
420
+
421
+ * Every PyTorch model can be fully captured
422
+ * Every discovered latent direction has a human meaning
423
+ * Every internal intervention corresponds to a naturally reachable state
424
+ * The recovered programme is globally minimal or unique
425
+ * The programme is faithful outside its validity envelope
426
+ * The method is state of the art across architectures
427
+ * A counterfactual is domain-valid without an application validator
428
+
429
+ Unsupported operations, weak interventional fidelity and unresolved concepts are shown rather than hidden.
430
+
431
+ ## Documentation
432
+
433
+ Start with:
434
+
435
+ * `docs/decompiler/ARCHITECTURE.md`
436
+ * `docs/decompiler/MECHANISM_IR.md`
437
+ * `docs/decompiler/MATHEMATICAL_FOUNDATIONS.md`
438
+ * `docs/decompiler/PYTORCH_2_13_BASIS.md`
439
+ * `docs/decompiler/INTERVENTION_COMPILER.md`
440
+ * `docs/decompiler/VALIDITY_CERTIFICATE.md`
441
+ * `docs/decompiler/VISUAL_SYSTEM.md`
442
+ * `docs/decompiler/RESEARCH_POSITIONING.md`
443
+ * `docs/decompiler/LIMITATIONS.md`
444
+ * `docs/decompiler/PUBLICATION_PLAN.md`
445
+ * `docs/decompiler/QUICKSTART.md`
446
+
447
+ ## Security and privacy
448
+
449
+ VRAVEN runs locally by default. Complete Python-pickled models are blocked unless the user explicitly enables trusted loading. Do not load untrusted pickles. Raw activations and input data are not persisted by the Mechanism IR unless a user explicitly exports them.
450
+
451
+ ## Licence
452
+
453
+ Apache License 2.0. See `LICENSE` and `NOTICE`.