causari 0.3.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.
- causari-0.3.0/LICENSE +202 -0
- causari-0.3.0/PKG-INFO +67 -0
- causari-0.3.0/README.md +39 -0
- causari-0.3.0/causari.egg-info/PKG-INFO +67 -0
- causari-0.3.0/causari.egg-info/SOURCES.txt +10 -0
- causari-0.3.0/causari.egg-info/dependency_links.txt +1 -0
- causari-0.3.0/causari.egg-info/entry_points.txt +3 -0
- causari-0.3.0/causari.egg-info/top_level.txt +1 -0
- causari-0.3.0/causari_shim/__init__.py +245 -0
- causari-0.3.0/pyproject.toml +42 -0
- causari-0.3.0/setup.cfg +4 -0
- causari-0.3.0/tests/test_shim.py +219 -0
causari-0.3.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.
|
causari-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: causari
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: AI-written code has no author. It has causes. Causari measures how many lines from AI-tagged commits are still alive in any git repo and records the prompt, model and files behind every agent edit.
|
|
5
|
+
Author-email: Crovia Trust <info@croviatrust.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://causari.dev
|
|
8
|
+
Project-URL: Method, https://causari.dev/method
|
|
9
|
+
Project-URL: Source, https://github.com/croviatrust/causari
|
|
10
|
+
Project-URL: Issues, https://github.com/croviatrust/causari/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/croviatrust/causari/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: ai,provenance,git,agents,mcp,audit,survival
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Rust
|
|
22
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# ∵ causari
|
|
30
|
+
|
|
31
|
+
**AI-written code has no author. It has causes. Causari records them.**
|
|
32
|
+
|
|
33
|
+
`re audit` reads plain git history, finds the commits that carry
|
|
34
|
+
machine-readable AI authorship (`Co-Authored-By` trailers, bot authors, agent
|
|
35
|
+
markers) and asks `git blame` how many of their lines are still at HEAD. A
|
|
36
|
+
count, not a grade. The same binary records the prompt, model and files behind
|
|
37
|
+
every agent edit into a local, append-only ledger.
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pipx run causari audit # the repo you are in
|
|
41
|
+
pipx run causari audit vercel/next.js
|
|
42
|
+
pip install causari && re audit # `re` is the short alias every example uses
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This package is a launcher, not the program. It holds no binary and does
|
|
46
|
+
nothing at `pip install`. On first run it downloads the release archive for
|
|
47
|
+
your platform from
|
|
48
|
+
`https://github.com/croviatrust/causari/releases/download/v<version>/`,
|
|
49
|
+
checks its SHA-256 against the release's `SHA256SUMS.txt`, unpacks `causari`
|
|
50
|
+
and `re` into `~/.cache/causari/<version>/<target>/` (`$XDG_CACHE_HOME` or
|
|
51
|
+
`%LOCALAPPDATA%` when set) and replaces itself with it (`execv`; a child
|
|
52
|
+
process on Windows). Exit code passes through. Standard library only; no
|
|
53
|
+
telemetry.
|
|
54
|
+
|
|
55
|
+
Prebuilt binaries exist for Linux (x86_64, aarch64), macOS (x86_64, Apple
|
|
56
|
+
silicon) and Windows (x86_64). Elsewhere, `cargo install causari --locked`.
|
|
57
|
+
|
|
58
|
+
| Variable | Effect |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `CAUSARI_VERSION` | run another release than the package version |
|
|
61
|
+
| `CAUSARI_BINARY` | path to a binary you already have; nothing is downloaded |
|
|
62
|
+
| `CAUSARI_DOWNLOAD_BASE` | mirror of the release directory (same layout, same `SHA256SUMS.txt`) |
|
|
63
|
+
|
|
64
|
+
Site and method: [causari.dev](https://causari.dev) ·
|
|
65
|
+
[causari.dev/method](https://causari.dev/method). Source, other installers and
|
|
66
|
+
the full command reference: [github.com/croviatrust/causari](https://github.com/croviatrust/causari).
|
|
67
|
+
Apache-2.0.
|
causari-0.3.0/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# ∵ causari
|
|
2
|
+
|
|
3
|
+
**AI-written code has no author. It has causes. Causari records them.**
|
|
4
|
+
|
|
5
|
+
`re audit` reads plain git history, finds the commits that carry
|
|
6
|
+
machine-readable AI authorship (`Co-Authored-By` trailers, bot authors, agent
|
|
7
|
+
markers) and asks `git blame` how many of their lines are still at HEAD. A
|
|
8
|
+
count, not a grade. The same binary records the prompt, model and files behind
|
|
9
|
+
every agent edit into a local, append-only ledger.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pipx run causari audit # the repo you are in
|
|
13
|
+
pipx run causari audit vercel/next.js
|
|
14
|
+
pip install causari && re audit # `re` is the short alias every example uses
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This package is a launcher, not the program. It holds no binary and does
|
|
18
|
+
nothing at `pip install`. On first run it downloads the release archive for
|
|
19
|
+
your platform from
|
|
20
|
+
`https://github.com/croviatrust/causari/releases/download/v<version>/`,
|
|
21
|
+
checks its SHA-256 against the release's `SHA256SUMS.txt`, unpacks `causari`
|
|
22
|
+
and `re` into `~/.cache/causari/<version>/<target>/` (`$XDG_CACHE_HOME` or
|
|
23
|
+
`%LOCALAPPDATA%` when set) and replaces itself with it (`execv`; a child
|
|
24
|
+
process on Windows). Exit code passes through. Standard library only; no
|
|
25
|
+
telemetry.
|
|
26
|
+
|
|
27
|
+
Prebuilt binaries exist for Linux (x86_64, aarch64), macOS (x86_64, Apple
|
|
28
|
+
silicon) and Windows (x86_64). Elsewhere, `cargo install causari --locked`.
|
|
29
|
+
|
|
30
|
+
| Variable | Effect |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `CAUSARI_VERSION` | run another release than the package version |
|
|
33
|
+
| `CAUSARI_BINARY` | path to a binary you already have; nothing is downloaded |
|
|
34
|
+
| `CAUSARI_DOWNLOAD_BASE` | mirror of the release directory (same layout, same `SHA256SUMS.txt`) |
|
|
35
|
+
|
|
36
|
+
Site and method: [causari.dev](https://causari.dev) ·
|
|
37
|
+
[causari.dev/method](https://causari.dev/method). Source, other installers and
|
|
38
|
+
the full command reference: [github.com/croviatrust/causari](https://github.com/croviatrust/causari).
|
|
39
|
+
Apache-2.0.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: causari
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: AI-written code has no author. It has causes. Causari measures how many lines from AI-tagged commits are still alive in any git repo and records the prompt, model and files behind every agent edit.
|
|
5
|
+
Author-email: Crovia Trust <info@croviatrust.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://causari.dev
|
|
8
|
+
Project-URL: Method, https://causari.dev/method
|
|
9
|
+
Project-URL: Source, https://github.com/croviatrust/causari
|
|
10
|
+
Project-URL: Issues, https://github.com/croviatrust/causari/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/croviatrust/causari/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: ai,provenance,git,agents,mcp,audit,survival
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Rust
|
|
22
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# ∵ causari
|
|
30
|
+
|
|
31
|
+
**AI-written code has no author. It has causes. Causari records them.**
|
|
32
|
+
|
|
33
|
+
`re audit` reads plain git history, finds the commits that carry
|
|
34
|
+
machine-readable AI authorship (`Co-Authored-By` trailers, bot authors, agent
|
|
35
|
+
markers) and asks `git blame` how many of their lines are still at HEAD. A
|
|
36
|
+
count, not a grade. The same binary records the prompt, model and files behind
|
|
37
|
+
every agent edit into a local, append-only ledger.
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pipx run causari audit # the repo you are in
|
|
41
|
+
pipx run causari audit vercel/next.js
|
|
42
|
+
pip install causari && re audit # `re` is the short alias every example uses
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This package is a launcher, not the program. It holds no binary and does
|
|
46
|
+
nothing at `pip install`. On first run it downloads the release archive for
|
|
47
|
+
your platform from
|
|
48
|
+
`https://github.com/croviatrust/causari/releases/download/v<version>/`,
|
|
49
|
+
checks its SHA-256 against the release's `SHA256SUMS.txt`, unpacks `causari`
|
|
50
|
+
and `re` into `~/.cache/causari/<version>/<target>/` (`$XDG_CACHE_HOME` or
|
|
51
|
+
`%LOCALAPPDATA%` when set) and replaces itself with it (`execv`; a child
|
|
52
|
+
process on Windows). Exit code passes through. Standard library only; no
|
|
53
|
+
telemetry.
|
|
54
|
+
|
|
55
|
+
Prebuilt binaries exist for Linux (x86_64, aarch64), macOS (x86_64, Apple
|
|
56
|
+
silicon) and Windows (x86_64). Elsewhere, `cargo install causari --locked`.
|
|
57
|
+
|
|
58
|
+
| Variable | Effect |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `CAUSARI_VERSION` | run another release than the package version |
|
|
61
|
+
| `CAUSARI_BINARY` | path to a binary you already have; nothing is downloaded |
|
|
62
|
+
| `CAUSARI_DOWNLOAD_BASE` | mirror of the release directory (same layout, same `SHA256SUMS.txt`) |
|
|
63
|
+
|
|
64
|
+
Site and method: [causari.dev](https://causari.dev) ·
|
|
65
|
+
[causari.dev/method](https://causari.dev/method). Source, other installers and
|
|
66
|
+
the full command reference: [github.com/croviatrust/causari](https://github.com/croviatrust/causari).
|
|
67
|
+
Apache-2.0.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
causari_shim
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"""Thin launcher for the causari release binaries.
|
|
2
|
+
|
|
3
|
+
On first run it downloads the archive for this platform from the GitHub
|
|
4
|
+
release that matches the installed package version, checks its SHA-256
|
|
5
|
+
against the release's SHA256SUMS.txt, unpacks ``causari`` and ``re`` into a
|
|
6
|
+
per-version cache and replaces itself with the requested one. Nothing
|
|
7
|
+
happens at ``pip install``: no network, no build step. Standard library only.
|
|
8
|
+
|
|
9
|
+
Environment:
|
|
10
|
+
CAUSARI_VERSION release to run (default: this package's version)
|
|
11
|
+
CAUSARI_BINARY path to an existing binary; skips the download
|
|
12
|
+
CAUSARI_DOWNLOAD_BASE where releases live (default: GitHub releases)
|
|
13
|
+
XDG_CACHE_HOME / LOCALAPPDATA cache root (default: ~/.cache)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import hashlib
|
|
19
|
+
import io
|
|
20
|
+
import os
|
|
21
|
+
import platform
|
|
22
|
+
import re
|
|
23
|
+
import shutil
|
|
24
|
+
import stat
|
|
25
|
+
import subprocess
|
|
26
|
+
import sys
|
|
27
|
+
import tarfile
|
|
28
|
+
import tempfile
|
|
29
|
+
import urllib.error
|
|
30
|
+
import urllib.request
|
|
31
|
+
import zipfile
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
from typing import Callable, Dict, Mapping, Optional
|
|
34
|
+
|
|
35
|
+
REPO = "croviatrust/causari"
|
|
36
|
+
DEFAULT_BASE = f"https://github.com/{REPO}/releases/download"
|
|
37
|
+
TIMEOUT_S = 60
|
|
38
|
+
|
|
39
|
+
TARGETS = {
|
|
40
|
+
("linux", "x86_64"): "x86_64-unknown-linux-gnu",
|
|
41
|
+
("linux", "aarch64"): "aarch64-unknown-linux-gnu",
|
|
42
|
+
("darwin", "x86_64"): "x86_64-apple-darwin",
|
|
43
|
+
("darwin", "aarch64"): "aarch64-apple-darwin",
|
|
44
|
+
("windows", "x86_64"): "x86_64-pc-windows-msvc",
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ShimError(Exception):
|
|
49
|
+
"""A failure the user can act on; printed as one line, exit 1."""
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def log(msg: str) -> None:
|
|
53
|
+
sys.stderr.write(f"causari: {msg}\n")
|
|
54
|
+
sys.stderr.flush()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# ---------------------------------------------------------------- platform
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def package_version() -> str:
|
|
61
|
+
try:
|
|
62
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
63
|
+
|
|
64
|
+
return version("causari")
|
|
65
|
+
except PackageNotFoundError:
|
|
66
|
+
pass
|
|
67
|
+
except Exception: # noqa: BLE001 - metadata backends vary; fall through
|
|
68
|
+
pass
|
|
69
|
+
# Source checkout without an installed distribution (tests, development).
|
|
70
|
+
pyproject = Path(__file__).resolve().parent.parent / "pyproject.toml"
|
|
71
|
+
m = re.search(r'^version = "([^"]+)"', pyproject.read_text(encoding="utf-8"), re.M)
|
|
72
|
+
if not m:
|
|
73
|
+
raise ShimError("cannot determine the causari version: package not installed and no pyproject.toml")
|
|
74
|
+
return m.group(1)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def resolve_version(env: Mapping[str, str]) -> str:
|
|
78
|
+
v = (env.get("CAUSARI_VERSION") or package_version()).strip()
|
|
79
|
+
return v[1:] if v.startswith("v") else v
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def target(system: Optional[str] = None, machine: Optional[str] = None) -> str:
|
|
83
|
+
system = (system or platform.system()).lower()
|
|
84
|
+
machine = (machine or platform.machine()).lower()
|
|
85
|
+
machine = {"amd64": "x86_64", "x64": "x86_64", "arm64": "aarch64"}.get(machine, machine)
|
|
86
|
+
t = TARGETS.get((system, machine))
|
|
87
|
+
if not t:
|
|
88
|
+
raise ShimError(
|
|
89
|
+
f"no prebuilt binary for {system}/{machine}. Releases cover Linux (x86_64, aarch64), "
|
|
90
|
+
"macOS (x86_64, Apple silicon) and Windows (x86_64). Build from source instead: "
|
|
91
|
+
"cargo install causari --locked"
|
|
92
|
+
)
|
|
93
|
+
return t
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def asset_name(version: str, tgt: str) -> str:
|
|
97
|
+
ext = "zip" if tgt.endswith("-windows-msvc") else "tar.gz"
|
|
98
|
+
return f"causari-v{version}-{tgt}.{ext}"
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def exe_name(name: str, tgt: str) -> str:
|
|
102
|
+
return f"{name}.exe" if tgt.endswith("-windows-msvc") else name
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def cache_root(env: Mapping[str, str], system: Optional[str] = None) -> Path:
|
|
106
|
+
if env.get("XDG_CACHE_HOME"):
|
|
107
|
+
return Path(env["XDG_CACHE_HOME"])
|
|
108
|
+
system = (system or platform.system()).lower()
|
|
109
|
+
if system == "windows" and env.get("LOCALAPPDATA"):
|
|
110
|
+
return Path(env["LOCALAPPDATA"])
|
|
111
|
+
return Path.home() / ".cache"
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def cache_dir(version: str, tgt: str, env: Mapping[str, str], system: Optional[str] = None) -> Path:
|
|
115
|
+
return cache_root(env, system) / "causari" / version / tgt
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# ---------------------------------------------------------------- download
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def fetch(url: str) -> bytes:
|
|
122
|
+
req = urllib.request.Request(url, headers={"User-Agent": f"causari-pypi-shim/{package_version()}", "Accept": "*/*"})
|
|
123
|
+
try:
|
|
124
|
+
with urllib.request.urlopen(req, timeout=TIMEOUT_S) as resp: # follows redirects
|
|
125
|
+
return resp.read()
|
|
126
|
+
except urllib.error.HTTPError as e:
|
|
127
|
+
raise ShimError(f"HTTP {e.code} fetching {url}") from e
|
|
128
|
+
except (urllib.error.URLError, OSError) as e:
|
|
129
|
+
raise ShimError(f"{e} fetching {url}") from e
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def expected_sum(sums_text: str, asset: str) -> str:
|
|
133
|
+
"""One line per file, ``<hex> <name>`` or ``<hex> *<name>`` (sha256sum format)."""
|
|
134
|
+
for raw in sums_text.splitlines():
|
|
135
|
+
m = re.match(r"^([0-9a-fA-F]{64})\s+\*?(.+)$", raw.strip())
|
|
136
|
+
if m and m.group(2).strip() == asset:
|
|
137
|
+
return m.group(1).lower()
|
|
138
|
+
raise ShimError(f"no checksum for {asset} in SHA256SUMS.txt; refusing to run an unverified download")
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def extract(asset: str, data: bytes, wanted: list) -> Dict[str, bytes]:
|
|
142
|
+
"""Return the wanted files (matched on base name) from a .tar.gz or .zip."""
|
|
143
|
+
out: Dict[str, bytes] = {}
|
|
144
|
+
if asset.endswith(".zip"):
|
|
145
|
+
with zipfile.ZipFile(io.BytesIO(data)) as zf:
|
|
146
|
+
for info in zf.infolist():
|
|
147
|
+
base = Path(info.filename).name
|
|
148
|
+
if base in wanted and not info.is_dir() and base not in out:
|
|
149
|
+
out[base] = zf.read(info)
|
|
150
|
+
else:
|
|
151
|
+
with tarfile.open(fileobj=io.BytesIO(data), mode="r:gz") as tf:
|
|
152
|
+
for member in tf:
|
|
153
|
+
base = Path(member.name).name
|
|
154
|
+
if base in wanted and member.isfile() and base not in out:
|
|
155
|
+
f = tf.extractfile(member)
|
|
156
|
+
if f is not None:
|
|
157
|
+
out[base] = f.read()
|
|
158
|
+
missing = [w for w in wanted if w not in out]
|
|
159
|
+
if missing:
|
|
160
|
+
raise ShimError(f"archive {asset} does not contain {', '.join(missing)}")
|
|
161
|
+
return out
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# ---------------------------------------------------------------- install
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def ensure_binary(
|
|
168
|
+
name: str,
|
|
169
|
+
env: Optional[Mapping[str, str]] = None,
|
|
170
|
+
fetcher: Callable[[str], bytes] = fetch,
|
|
171
|
+
system: Optional[str] = None,
|
|
172
|
+
machine: Optional[str] = None,
|
|
173
|
+
) -> Path:
|
|
174
|
+
env = os.environ if env is None else env
|
|
175
|
+
if env.get("CAUSARI_BINARY"):
|
|
176
|
+
p = Path(env["CAUSARI_BINARY"])
|
|
177
|
+
if not p.is_file():
|
|
178
|
+
raise ShimError(f"CAUSARI_BINARY={p} does not exist")
|
|
179
|
+
return p
|
|
180
|
+
|
|
181
|
+
version = resolve_version(env)
|
|
182
|
+
tgt = target(system, machine)
|
|
183
|
+
directory = cache_dir(version, tgt, env, system)
|
|
184
|
+
wanted = [exe_name(n, tgt) for n in ("causari", "re")]
|
|
185
|
+
binary = directory / exe_name(name, tgt)
|
|
186
|
+
if binary.is_file():
|
|
187
|
+
return binary
|
|
188
|
+
|
|
189
|
+
base = (env.get("CAUSARI_DOWNLOAD_BASE") or DEFAULT_BASE).rstrip("/")
|
|
190
|
+
asset = asset_name(version, tgt)
|
|
191
|
+
log(f"first run: downloading causari v{version} ({tgt}) from {base}/v{version}/")
|
|
192
|
+
sums = fetcher(f"{base}/v{version}/SHA256SUMS.txt").decode("utf-8", errors="replace")
|
|
193
|
+
expected = expected_sum(sums, asset)
|
|
194
|
+
archive = fetcher(f"{base}/v{version}/{asset}")
|
|
195
|
+
actual = hashlib.sha256(archive).hexdigest()
|
|
196
|
+
if actual != expected:
|
|
197
|
+
raise ShimError(f"sha256 mismatch for {asset}: expected {expected}, got {actual}; refusing to run it")
|
|
198
|
+
files = extract(asset, archive, wanted)
|
|
199
|
+
|
|
200
|
+
# Unpack next to the final directory, then rename: a concurrent first run
|
|
201
|
+
# either wins the rename or finds the winner's files in place.
|
|
202
|
+
directory.parent.mkdir(parents=True, exist_ok=True)
|
|
203
|
+
tmp = Path(tempfile.mkdtemp(prefix=f".{tgt}-", dir=directory.parent))
|
|
204
|
+
try:
|
|
205
|
+
for file, content in files.items():
|
|
206
|
+
p = tmp / file
|
|
207
|
+
p.write_bytes(content)
|
|
208
|
+
p.chmod(p.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
209
|
+
try:
|
|
210
|
+
os.rename(tmp, directory)
|
|
211
|
+
except OSError:
|
|
212
|
+
if not binary.is_file():
|
|
213
|
+
raise
|
|
214
|
+
finally:
|
|
215
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
216
|
+
log(f"sha256 verified ({actual}); cached in {directory}")
|
|
217
|
+
return binary
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# ---------------------------------------------------------------- run
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def run(name: str, args: Optional[list] = None) -> int:
|
|
224
|
+
args = sys.argv[1:] if args is None else args
|
|
225
|
+
try:
|
|
226
|
+
binary = ensure_binary(name)
|
|
227
|
+
except ShimError as e:
|
|
228
|
+
log(str(e))
|
|
229
|
+
return 1
|
|
230
|
+
if os.name == "posix":
|
|
231
|
+
os.execv(str(binary), [str(binary), *args]) # does not return
|
|
232
|
+
# Windows has no exec that replaces the process: run as a child and
|
|
233
|
+
# relay its exit code; Ctrl-C reaches the child through the console.
|
|
234
|
+
try:
|
|
235
|
+
return subprocess.call([str(binary), *args])
|
|
236
|
+
except KeyboardInterrupt:
|
|
237
|
+
return 130
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def main_causari() -> None:
|
|
241
|
+
sys.exit(run("causari"))
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def main_re() -> None:
|
|
245
|
+
sys.exit(run("re"))
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "causari"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
description = "AI-written code has no author. It has causes. Causari measures how many lines from AI-tagged commits are still alive in any git repo and records the prompt, model and files behind every agent edit."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "Crovia Trust", email = "info@croviatrust.com" }]
|
|
13
|
+
requires-python = ">=3.9"
|
|
14
|
+
dependencies = []
|
|
15
|
+
keywords = ["ai", "provenance", "git", "agents", "mcp", "audit", "survival"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Operating System :: MacOS",
|
|
21
|
+
"Operating System :: Microsoft :: Windows",
|
|
22
|
+
"Operating System :: POSIX :: Linux",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
25
|
+
"Programming Language :: Rust",
|
|
26
|
+
"Topic :: Software Development :: Version Control :: Git",
|
|
27
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://causari.dev"
|
|
32
|
+
Method = "https://causari.dev/method"
|
|
33
|
+
Source = "https://github.com/croviatrust/causari"
|
|
34
|
+
Issues = "https://github.com/croviatrust/causari/issues"
|
|
35
|
+
Changelog = "https://github.com/croviatrust/causari/blob/main/CHANGELOG.md"
|
|
36
|
+
|
|
37
|
+
[project.scripts]
|
|
38
|
+
causari = "causari_shim:main_causari"
|
|
39
|
+
re = "causari_shim:main_re"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools]
|
|
42
|
+
packages = ["causari_shim"]
|
causari-0.3.0/setup.cfg
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"""Unit tests for the PyPI launcher. No network: every download goes through
|
|
2
|
+
a fake fetcher that serves an in-memory release."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import hashlib
|
|
7
|
+
import io
|
|
8
|
+
import os
|
|
9
|
+
import stat
|
|
10
|
+
import sys
|
|
11
|
+
import tarfile
|
|
12
|
+
import tempfile
|
|
13
|
+
import unittest
|
|
14
|
+
import zipfile
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
18
|
+
|
|
19
|
+
import causari_shim as shim # noqa: E402
|
|
20
|
+
|
|
21
|
+
VERSION = "9.9.9"
|
|
22
|
+
LINUX = "x86_64-unknown-linux-gnu"
|
|
23
|
+
WINDOWS = "x86_64-pc-windows-msvc"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def fake_tar(files: dict) -> bytes:
|
|
27
|
+
buf = io.BytesIO()
|
|
28
|
+
with tarfile.open(fileobj=buf, mode="w:gz") as tf:
|
|
29
|
+
for name, content in files.items():
|
|
30
|
+
info = tarfile.TarInfo(name)
|
|
31
|
+
info.size = len(content)
|
|
32
|
+
info.mode = 0o755
|
|
33
|
+
tf.addfile(info, io.BytesIO(content))
|
|
34
|
+
return buf.getvalue()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def fake_zip(files: dict) -> bytes:
|
|
38
|
+
buf = io.BytesIO()
|
|
39
|
+
with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zf:
|
|
40
|
+
for name, content in files.items():
|
|
41
|
+
zf.writestr(name, content)
|
|
42
|
+
return buf.getvalue()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Release:
|
|
46
|
+
"""An in-memory release directory served by ``fetch``."""
|
|
47
|
+
|
|
48
|
+
def __init__(self, asset: str, archive: bytes, sums: str | None = None) -> None:
|
|
49
|
+
self.asset = asset
|
|
50
|
+
self.archive = archive
|
|
51
|
+
self.sums = sums if sums is not None else f"{hashlib.sha256(archive).hexdigest()} {asset}\n"
|
|
52
|
+
self.requests: list = []
|
|
53
|
+
|
|
54
|
+
def fetch(self, url: str) -> bytes:
|
|
55
|
+
self.requests.append(url)
|
|
56
|
+
if url.endswith("/SHA256SUMS.txt"):
|
|
57
|
+
return self.sums.encode()
|
|
58
|
+
if url.endswith("/" + self.asset):
|
|
59
|
+
return self.archive
|
|
60
|
+
raise shim.ShimError(f"HTTP 404 fetching {url}")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def refuse(url: str) -> bytes:
|
|
64
|
+
raise AssertionError(f"network access attempted: {url}")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class ShimTests(unittest.TestCase):
|
|
68
|
+
def setUp(self) -> None:
|
|
69
|
+
self.tmp = tempfile.TemporaryDirectory()
|
|
70
|
+
self.env = {"XDG_CACHE_HOME": self.tmp.name, "CAUSARI_VERSION": VERSION}
|
|
71
|
+
self.linux_asset = shim.asset_name(VERSION, LINUX)
|
|
72
|
+
self.linux_bins = {"causari": b"#!/bin/sh\necho causari\n", "re": b"#!/bin/sh\necho re\n"}
|
|
73
|
+
self.logged: list = []
|
|
74
|
+
self._log = shim.log
|
|
75
|
+
shim.log = self.logged.append
|
|
76
|
+
|
|
77
|
+
def tearDown(self) -> None:
|
|
78
|
+
shim.log = self._log
|
|
79
|
+
self.tmp.cleanup()
|
|
80
|
+
|
|
81
|
+
def cache(self, tgt: str) -> Path:
|
|
82
|
+
return Path(self.tmp.name) / "causari" / VERSION / tgt
|
|
83
|
+
|
|
84
|
+
# --- platform ------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
def test_targets(self) -> None:
|
|
87
|
+
self.assertEqual(shim.target("Linux", "x86_64"), LINUX)
|
|
88
|
+
self.assertEqual(shim.target("Linux", "aarch64"), "aarch64-unknown-linux-gnu")
|
|
89
|
+
self.assertEqual(shim.target("Darwin", "arm64"), "aarch64-apple-darwin")
|
|
90
|
+
self.assertEqual(shim.target("Darwin", "x86_64"), "x86_64-apple-darwin")
|
|
91
|
+
self.assertEqual(shim.target("Windows", "AMD64"), WINDOWS)
|
|
92
|
+
|
|
93
|
+
def test_unsupported_platform_names_itself_and_the_source_build(self) -> None:
|
|
94
|
+
with self.assertRaises(shim.ShimError) as cm:
|
|
95
|
+
shim.target("FreeBSD", "x86_64")
|
|
96
|
+
self.assertIn("freebsd/x86_64", str(cm.exception))
|
|
97
|
+
self.assertIn("cargo install causari --locked", str(cm.exception))
|
|
98
|
+
with self.assertRaises(shim.ShimError):
|
|
99
|
+
shim.target("Windows", "ARM64")
|
|
100
|
+
|
|
101
|
+
def test_version_env_strips_v(self) -> None:
|
|
102
|
+
self.assertEqual(shim.resolve_version({"CAUSARI_VERSION": "v1.2.3"}), "1.2.3")
|
|
103
|
+
self.assertEqual(shim.resolve_version({"CAUSARI_VERSION": "1.2.3"}), "1.2.3")
|
|
104
|
+
self.assertRegex(shim.resolve_version({}), r"^\d+\.\d+\.\d+$")
|
|
105
|
+
|
|
106
|
+
def test_asset_names(self) -> None:
|
|
107
|
+
self.assertEqual(shim.asset_name("0.2.0", LINUX), "causari-v0.2.0-x86_64-unknown-linux-gnu.tar.gz")
|
|
108
|
+
self.assertEqual(shim.asset_name("0.2.0", WINDOWS), "causari-v0.2.0-x86_64-pc-windows-msvc.zip")
|
|
109
|
+
|
|
110
|
+
def test_cache_root(self) -> None:
|
|
111
|
+
self.assertEqual(shim.cache_root({"XDG_CACHE_HOME": "/x"}), Path("/x"))
|
|
112
|
+
self.assertEqual(shim.cache_root({"LOCALAPPDATA": r"C:\L"}, "Windows"), Path(r"C:\L"))
|
|
113
|
+
self.assertEqual(shim.cache_root({"LOCALAPPDATA": r"C:\L"}, "Linux"), Path.home() / ".cache")
|
|
114
|
+
|
|
115
|
+
# --- checksums ------------------------------------------------------
|
|
116
|
+
|
|
117
|
+
def test_expected_sum_parses_sha256sum_formats(self) -> None:
|
|
118
|
+
h = "a" * 64
|
|
119
|
+
self.assertEqual(shim.expected_sum(f"{h} x.tar.gz\n", "x.tar.gz"), h)
|
|
120
|
+
self.assertEqual(shim.expected_sum(f"{h} *x.tar.gz\r\n", "x.tar.gz"), h)
|
|
121
|
+
self.assertEqual(shim.expected_sum(f"{'b' * 64} y.tar.gz\n{h} x.tar.gz\n", "x.tar.gz"), h)
|
|
122
|
+
with self.assertRaises(shim.ShimError) as cm:
|
|
123
|
+
shim.expected_sum(f"{h} y.tar.gz\n", "x.tar.gz")
|
|
124
|
+
self.assertIn("no checksum for x.tar.gz", str(cm.exception))
|
|
125
|
+
|
|
126
|
+
def test_checksum_mismatch_refuses_and_caches_nothing(self) -> None:
|
|
127
|
+
archive = fake_tar(self.linux_bins)
|
|
128
|
+
tampered = Release(self.linux_asset, archive, sums=f"{'0' * 64} {self.linux_asset}\n")
|
|
129
|
+
with self.assertRaises(shim.ShimError) as cm:
|
|
130
|
+
shim.ensure_binary("re", self.env, tampered.fetch, "Linux", "x86_64")
|
|
131
|
+
self.assertIn("sha256 mismatch", str(cm.exception))
|
|
132
|
+
self.assertFalse(self.cache(LINUX).exists())
|
|
133
|
+
self.assertFalse(any(p.is_dir() for p in self.cache(LINUX).parent.glob(".*")) if self.cache(LINUX).parent.exists() else False)
|
|
134
|
+
|
|
135
|
+
def test_missing_asset_in_sums_refuses(self) -> None:
|
|
136
|
+
archive = fake_tar(self.linux_bins)
|
|
137
|
+
rel = Release(self.linux_asset, archive, sums=f"{'0' * 64} other.tar.gz\n")
|
|
138
|
+
with self.assertRaises(shim.ShimError) as cm:
|
|
139
|
+
shim.ensure_binary("re", self.env, rel.fetch, "Linux", "x86_64")
|
|
140
|
+
self.assertIn("no checksum for", str(cm.exception))
|
|
141
|
+
self.assertEqual(len(rel.requests), 1, "the archive is not fetched without a checksum to hold it to")
|
|
142
|
+
|
|
143
|
+
# --- install --------------------------------------------------------
|
|
144
|
+
|
|
145
|
+
def test_first_run_downloads_verifies_and_caches_both_names(self) -> None:
|
|
146
|
+
rel = Release(self.linux_asset, fake_tar(self.linux_bins))
|
|
147
|
+
binary = shim.ensure_binary("re", self.env, rel.fetch, "Linux", "x86_64")
|
|
148
|
+
self.assertEqual(binary, self.cache(LINUX) / "re")
|
|
149
|
+
self.assertEqual(binary.read_bytes(), self.linux_bins["re"])
|
|
150
|
+
self.assertEqual((self.cache(LINUX) / "causari").read_bytes(), self.linux_bins["causari"])
|
|
151
|
+
self.assertTrue(binary.stat().st_mode & stat.S_IXUSR)
|
|
152
|
+
self.assertEqual(
|
|
153
|
+
rel.requests,
|
|
154
|
+
[
|
|
155
|
+
f"{shim.DEFAULT_BASE}/v{VERSION}/SHA256SUMS.txt",
|
|
156
|
+
f"{shim.DEFAULT_BASE}/v{VERSION}/{self.linux_asset}",
|
|
157
|
+
],
|
|
158
|
+
)
|
|
159
|
+
self.assertEqual([p.name for p in self.cache(LINUX).parent.iterdir()], [LINUX], "no temp dir left behind")
|
|
160
|
+
self.assertTrue(any(m.startswith("first run: downloading") for m in self.logged), self.logged)
|
|
161
|
+
self.assertTrue(any(m.startswith("sha256 verified") for m in self.logged), self.logged)
|
|
162
|
+
|
|
163
|
+
def test_cache_hit_makes_no_request(self) -> None:
|
|
164
|
+
d = self.cache(LINUX)
|
|
165
|
+
d.mkdir(parents=True)
|
|
166
|
+
(d / "causari").write_bytes(b"cached")
|
|
167
|
+
binary = shim.ensure_binary("causari", self.env, refuse, "Linux", "x86_64")
|
|
168
|
+
self.assertEqual(binary, d / "causari")
|
|
169
|
+
|
|
170
|
+
def test_download_base_override(self) -> None:
|
|
171
|
+
env = dict(self.env, CAUSARI_DOWNLOAD_BASE="https://mirror.example/causari/")
|
|
172
|
+
rel = Release(self.linux_asset, fake_tar(self.linux_bins))
|
|
173
|
+
shim.ensure_binary("re", env, rel.fetch, "Linux", "x86_64")
|
|
174
|
+
self.assertTrue(all(u.startswith(f"https://mirror.example/causari/v{VERSION}/") for u in rel.requests), rel.requests)
|
|
175
|
+
|
|
176
|
+
def test_windows_zip_yields_exe_names(self) -> None:
|
|
177
|
+
asset = shim.asset_name(VERSION, WINDOWS)
|
|
178
|
+
rel = Release(asset, fake_zip({"causari.exe": b"MZcausari", "re.exe": b"MZre"}))
|
|
179
|
+
binary = shim.ensure_binary("re", self.env, rel.fetch, "Windows", "AMD64")
|
|
180
|
+
self.assertEqual(binary, self.cache(WINDOWS) / "re.exe")
|
|
181
|
+
self.assertEqual(binary.read_bytes(), b"MZre")
|
|
182
|
+
|
|
183
|
+
def test_archive_missing_a_binary_is_refused(self) -> None:
|
|
184
|
+
rel = Release(self.linux_asset, fake_tar({"re": b"only re"}))
|
|
185
|
+
with self.assertRaises(shim.ShimError) as cm:
|
|
186
|
+
shim.ensure_binary("re", self.env, rel.fetch, "Linux", "x86_64")
|
|
187
|
+
self.assertIn("does not contain causari", str(cm.exception))
|
|
188
|
+
self.assertFalse(self.cache(LINUX).exists())
|
|
189
|
+
|
|
190
|
+
def test_archive_with_directory_prefix_is_accepted(self) -> None:
|
|
191
|
+
rel = Release(self.linux_asset, fake_tar({"causari-v9/causari": b"c", "causari-v9/re": b"r"}))
|
|
192
|
+
binary = shim.ensure_binary("re", self.env, rel.fetch, "Linux", "x86_64")
|
|
193
|
+
self.assertEqual(binary.read_bytes(), b"r")
|
|
194
|
+
|
|
195
|
+
def test_causari_binary_env_skips_download(self) -> None:
|
|
196
|
+
own = Path(self.tmp.name) / "my-re"
|
|
197
|
+
own.write_bytes(b"mine")
|
|
198
|
+
env = dict(self.env, CAUSARI_BINARY=str(own))
|
|
199
|
+
self.assertEqual(shim.ensure_binary("re", env, refuse, "Linux", "x86_64"), own)
|
|
200
|
+
env["CAUSARI_BINARY"] = str(Path(self.tmp.name) / "missing")
|
|
201
|
+
with self.assertRaises(shim.ShimError) as cm:
|
|
202
|
+
shim.ensure_binary("re", env, refuse, "Linux", "x86_64")
|
|
203
|
+
self.assertIn("does not exist", str(cm.exception))
|
|
204
|
+
|
|
205
|
+
# --- run ------------------------------------------------------------
|
|
206
|
+
|
|
207
|
+
def test_run_reports_shim_errors_with_exit_1(self) -> None:
|
|
208
|
+
env = dict(self.env, CAUSARI_BINARY=str(Path(self.tmp.name) / "missing"))
|
|
209
|
+
old = dict(os.environ)
|
|
210
|
+
os.environ.update(env)
|
|
211
|
+
try:
|
|
212
|
+
self.assertEqual(shim.run("re", ["--version"]), 1)
|
|
213
|
+
finally:
|
|
214
|
+
os.environ.clear()
|
|
215
|
+
os.environ.update(old)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
if __name__ == "__main__":
|
|
219
|
+
unittest.main()
|