crovia 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.
Files changed (38) hide show
  1. crovia-0.1.0/LICENSE +167 -0
  2. crovia-0.1.0/NOTICE +11 -0
  3. crovia-0.1.0/PKG-INFO +369 -0
  4. crovia-0.1.0/README.md +354 -0
  5. crovia-0.1.0/check_floors_vs_payouts.py +219 -0
  6. crovia-0.1.0/compliance_ai_act.py +457 -0
  7. crovia-0.1.0/crovia/__init__.py +13 -0
  8. crovia-0.1.0/crovia/cli.py +985 -0
  9. crovia-0.1.0/crovia/sentinel_v0_2.py +227 -0
  10. crovia-0.1.0/crovia.egg-info/PKG-INFO +369 -0
  11. crovia-0.1.0/crovia.egg-info/SOURCES.txt +36 -0
  12. crovia-0.1.0/crovia.egg-info/dependency_links.txt +1 -0
  13. crovia-0.1.0/crovia.egg-info/entry_points.txt +3 -0
  14. crovia-0.1.0/crovia.egg-info/requires.txt +3 -0
  15. crovia-0.1.0/crovia.egg-info/top_level.txt +22 -0
  16. crovia-0.1.0/crovia_app.py +992 -0
  17. crovia-0.1.0/crovia_floor.py +376 -0
  18. crovia-0.1.0/crovia_trust.py +433 -0
  19. crovia-0.1.0/crovia_validate.py +376 -0
  20. crovia-0.1.0/csv_to_royalty.py +86 -0
  21. crovia-0.1.0/dpi_to_royalty.py +238 -0
  22. crovia-0.1.0/events_to_royalty.py +155 -0
  23. crovia-0.1.0/generate_receipts.py +154 -0
  24. crovia-0.1.0/generate_synthetic_receipts.py +65 -0
  25. crovia-0.1.0/hashchain_writer.py +118 -0
  26. crovia-0.1.0/make_payout_charts.py +157 -0
  27. crovia-0.1.0/ndjson_io.py +30 -0
  28. crovia-0.1.0/payouts_from_royalties.py +501 -0
  29. crovia-0.1.0/pyproject.toml +59 -0
  30. crovia-0.1.0/qa_receipts.py +30 -0
  31. crovia-0.1.0/run_period.py +300 -0
  32. crovia-0.1.0/schema.py +267 -0
  33. crovia-0.1.0/setup.cfg +4 -0
  34. crovia-0.1.0/src/crovia_spider/__init__.py +10 -0
  35. crovia-0.1.0/src/crovia_spider/cli.py +132 -0
  36. crovia-0.1.0/src/crovia_spider/version.py +1 -0
  37. crovia-0.1.0/trust_bundle_validator.py +157 -0
  38. crovia-0.1.0/verify_hashchain.py +196 -0
crovia-0.1.0/LICENSE ADDED
@@ -0,0 +1,167 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including
48
+ the original version of the Work and any modifications or additions
49
+ to that Work or Derivative Works thereof, that is intentionally
50
+ submitted to Licensor for inclusion in the Work by the copyright owner
51
+ or by an individual or Legal Entity authorized to submit on behalf of
52
+ the copyright owner. For the purposes of this definition, "submitted"
53
+ means any form of electronic, verbal, or written communication sent
54
+ to the Licensor or its representatives, including but not limited to
55
+ communication on electronic mailing lists, source code control systems,
56
+ and issue tracking systems that are managed by, or on behalf of, the
57
+ Licensor for the purpose of discussing and improving the Work, but
58
+ excluding communication that is conspicuously marked or otherwise
59
+ designated in writing by the copyright owner as "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity
62
+ on behalf of whom a Contribution has been received by Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License.
66
+
67
+ Subject to the terms and conditions of this License, each Contributor
68
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
69
+ royalty-free, irrevocable copyright license to reproduce, prepare
70
+ Derivative Works of, publicly display, publicly perform, sublicense,
71
+ and distribute the Work and such Derivative Works in Source or Object
72
+ form.
73
+
74
+ 3. Grant of Patent License.
75
+
76
+ Subject to the terms and conditions of this License, each Contributor
77
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
78
+ royalty-free, irrevocable (except as stated in this section) patent
79
+ license to make, have made, use, offer to sell, sell, import, and
80
+ otherwise transfer the Work, where such license applies only to those
81
+ patent claims licensable by such Contributor that are necessarily
82
+ infringed by their Contribution(s) alone or by combination of their
83
+ Contribution(s) with the Work to which such Contribution(s) was submitted.
84
+ If You institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
86
+ Contribution incorporated within the Work constitutes direct or
87
+ contributory patent infringement, then any patent licenses granted to
88
+ You under this License for that Work shall terminate as of the date such
89
+ litigation is filed.
90
+
91
+ 4. Redistribution.
92
+
93
+ You may reproduce and distribute copies of the Work or Derivative Works
94
+ thereof in any medium, with or without modifications, and in Source or
95
+ Object form, provided that You meet the following conditions:
96
+
97
+ (a) You must give any other recipients of the Work or Derivative Works
98
+ a copy of this License; and
99
+
100
+ (b) You must cause any modified files to carry prominent notices stating
101
+ that You changed the files; and
102
+
103
+ (c) You must retain, in the Source form of any Derivative Works that
104
+ You distribute, all copyright, patent, trademark, and attribution
105
+ notices from the Source form of the Work, excluding those notices
106
+ that do not pertain to any part of the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file.
112
+
113
+ 5. Submission of Contributions.
114
+
115
+ Unless You explicitly state otherwise, any Contribution intentionally
116
+ submitted for inclusion in the Work by You shall be under the terms and
117
+ conditions of this License, without any additional terms or conditions.
118
+
119
+ 6. Trademarks.
120
+
121
+ Nothing in this License grants permission to use the trade names,
122
+ trademarks, service marks, or product names of the Licensor, except as
123
+ required for reasonable and customary use in describing the origin of
124
+ the Work.
125
+
126
+ 7. Disclaimer of Warranty.
127
+
128
+ Unless required by applicable law or agreed to in writing, Licensor
129
+ provides the Work (and each Contributor provides its Contributions) on
130
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
131
+ express or implied, including, without limitation, any warranties or
132
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
133
+ A PARTICULAR PURPOSE. You are solely responsible for determining the
134
+ appropriateness of using or redistributing the Work.
135
+
136
+ 8. Limitation of Liability.
137
+
138
+ In no event and under no legal theory, whether in tort (including
139
+ negligence), contract, or otherwise, unless required by applicable law
140
+ (such as deliberate and grossly negligent acts) or agreed to in writing,
141
+ shall any Contributor be liable to You for damages, including any
142
+ direct, indirect, special, incidental, or consequential damages of any
143
+ character arising as a result of this License or the use of the Work.
144
+
145
+ 9. Accepting Warranty or Additional Liability.
146
+
147
+ While redistributing the Work or Derivative Works thereof, You may
148
+ choose to offer additional liability obligations. However, absent such
149
+ an agreement, you may not do so.
150
+
151
+ END OF TERMS AND CONDITIONS
152
+
153
+ APPENDIX: How to apply the Apache License to your work.
154
+
155
+ Copyright 2025 Tarik En Nakhai
156
+
157
+ Licensed under the Apache License, Version 2.0 (the "License");
158
+ you may not use this file except in compliance with the License.
159
+ You may obtain a copy of the License at
160
+
161
+ http://www.apache.org/licenses/LICENSE-2.0
162
+
163
+ Unless required by applicable law or agreed to in writing, software
164
+ distributed under the License is distributed on an "AS IS" BASIS,
165
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
166
+ See the License for the specific language governing permissions and
167
+ limitations under the License.
crovia-0.1.0/NOTICE ADDED
@@ -0,0 +1,11 @@
1
+ Crovia Core Engine
2
+ Copyright 2025 Tarik En Nakhai
3
+
4
+ This product includes components developed by Crovia Trust.
5
+ Website: https://croviatrust.com
6
+
7
+ First canonical trust bundle:
8
+ CTB-2025-11-HF------8559
9
+
10
+ "CROVIA" and "Crovia Trust" are trademarks of Tarik En Nakhai.
11
+
crovia-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,369 @@
1
+ Metadata-Version: 2.4
2
+ Name: crovia
3
+ Version: 0.1.0
4
+ Summary: CroviaTrust – Open-core evidence & payout engine for AI datasets
5
+ Author: CroviaTrust
6
+ License: Apache-2.0
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ License-File: NOTICE
11
+ Requires-Dist: numpy
12
+ Requires-Dist: pandas
13
+ Requires-Dist: matplotlib
14
+ Dynamic: license-file
15
+
16
+ # Crovia Spider
17
+
18
+ **“If it’s already in the open training datasets of 2025–2026, it already has a Crovia receipt.”**
19
+
20
+ Crovia Spider turns existing open training corpora (e.g. LAION, C4, The Stack) into
21
+ standardized `spider_receipt.v1` NDJSON logs.
22
+
23
+ A `spider_receipt.v1` is the minimal unit of Crovia's awareness of a content item
24
+ in the training data ecosystem.
25
+
26
+ This repository contains:
27
+
28
+ - the formal spec: `docs/CROVIA_SPIDER_RECEIPT_v1.md`
29
+ - a reference implementation to generate receipts from LAION-style metadata
30
+ - a CLI: `crovia-spider from-laion ...`
31
+
32
+ ## Quick start
33
+
34
+ Clone and install:
35
+
36
+ git clone https://github.com/croviatrust/crovia-spider.git
37
+ cd crovia-spider
38
+
39
+ python -m venv .venv
40
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
41
+
42
+ pip install -U pip
43
+ pip install .
44
+
45
+ crovia-spider --help
46
+
47
+ Example (LAION-style Parquet → spider_receipt NDJSON):
48
+
49
+ crovia-spider from-laion \
50
+ --metadata-path /data/laion/laion2B-en-meta.parquet \
51
+ --out data/receipts_laion_sample.ndjson \
52
+ --period 2025-12 \
53
+ --sample 100000
54
+
55
+ This will produce an NDJSON file where each line is a valid `spider_receipt.v1`.
56
+
57
+ See `docs/CROVIA_SPIDER_RECEIPT_v1.md` for the full specification.
58
+
59
+ ---
60
+
61
+ ## CROVIA Spider – Real evidence runs
62
+
63
+ - **GSM8K (OpenAI math word problems, HF mirror `oieieio/gsm8k`)**
64
+ - Period: 2025-12
65
+ - Receipts: 7,473 `spider_receipt.v1` entries
66
+ - Docs: [docs/README_SPIDER_GSM8K_2025-12.md](docs/README_SPIDER_GSM8K_2025-12.md)
67
+
68
+ HEAD
69
+ ```bash
70
+ cd /opt/crovia
71
+ python -m venv .venv
72
+ source .venv/bin/activate
73
+ pip install -r requirements.txt
74
+ ```
75
+
76
+ ## 2.2 Full period run
77
+
78
+ ```bash
79
+ python run_period.py \
80
+ --period 2025-11 \
81
+ --eur-total 1000000 \
82
+ --receipts data/royalty_from_faiss.ndjson \
83
+ --min-appear 1
84
+ ```
85
+
86
+ This will:
87
+
88
+ * Run QA
89
+ * Compute trust metrics
90
+ * (Optional) run schema validation (`crovia_validate.py`)
91
+ * (Optional) run AI-Act helpers (`compliance_ai_act.py`)
92
+ * Compute payouts
93
+ * Generate charts
94
+ * Build & verify a hash-chain
95
+ * Compute Crovian Floors
96
+ * (Optional) build a Trust Bundle
97
+
98
+ Artifacts generated:
99
+
100
+ ```text
101
+ data/trust_providers.csv
102
+ docs/trust_summary.md
103
+ data/payouts_2025-11.csv
104
+ data/payouts_2025-11.ndjson
105
+ data/floors_2025-11.json
106
+ charts/payout_top10_2025-11.png
107
+ charts/payout_cumulative_2025-11.png
108
+ proofs/hashchain_*.txt
109
+ ```
110
+
111
+ For a detailed operator view, see:
112
+
113
+ ```text
114
+ docs/CROVIA_OPEN_CORE_FAISS_2025-11_OVERVIEW.md
115
+ ```
116
+
117
+ ---
118
+
119
+ ## 2.3 Running the entire demo via C-LINE (recommended)
120
+
121
+ C-LINE is the unified command-line interface for the CROVIA Core Engine.
122
+ It wraps all internal scripts (validation, trust, payouts, floors, hash-chain,
123
+ AI Act helpers, ZIP evidence builder) into a single, user-friendly CLI.
124
+
125
+ Run the full 2025-11 demo with one command:
126
+
127
+ ```bash
128
+ python tools/c_line.py demo
129
+ # future installation:
130
+ # c-line demo
131
+ ```
132
+
133
+ This will automatically:
134
+
135
+ * validate the receipts NDJSON
136
+ * run trust aggregation
137
+ * compute payouts (`payouts.v1`)
138
+ * generate payout charts
139
+ * compute **Crovian Floors v1.1**
140
+ * run **AI Act Annex-IV documentation** helpers
141
+ * write a **SHA-256 hash-chain** and verify it
142
+ * collect all artifacts into a **ZIP evidence pack**
143
+ * generate a **QR code** pointing to the pack
144
+
145
+ Artifacts produced:
146
+
147
+ ```text
148
+ evidence/CROVIA_evidence_2025-11.zip
149
+ proofs/QR_evidence_2025-11.png
150
+ docs/VALIDATE_report_2025-11.md
151
+ docs/AI_ACT_summary_2025-11.md
152
+ data/payouts_2025-11.csv
153
+ data/floors_2025-11.json
154
+ # plus ~30 additional files: charts, logs, packs, proofs
155
+ ```
156
+
157
+ **C-LINE v1.0** turns the CROVIA demo into a *single-shot reproducible evidence pipeline*.
158
+
159
+ # 2.4 Install as a CLI (C-LINE)
160
+
161
+ You can also install the CROVIA Core Engine as a local CLI inside a virtualenv:
162
+
163
+ ```bash
164
+ pip install -e .
165
+ c-line demo
166
+ ```
167
+ This will install the c-line entrypoint in your environment and run the full
168
+ CROVIA demo pipeline (validation → trust → payouts → floors → hash-chain →
169
+ AI Act helpers → ZIP + QR evidence pack) with a single command.
170
+
171
+ # 3. DPI demo – Trust Bundle example
172
+
173
+ The repository includes a small DPI demo showing:
174
+
175
+ * DPI-based `royalty_receipt.v1` logs
176
+ * payouts, floors, trust CSVs
177
+ * AI Act-style documentation
178
+ * SHA-256 evidence digests consolidated in `trust_bundle.v1`
179
+
180
+ Validate the bundle:
181
+
182
+ ```bash
183
+ python trust_bundle_validator.py \
184
+ --bundle demo_dpi_2025-11/output/trust_bundle_2025-11.json \
185
+ --base-dir /opt/crovia
186
+ ```
187
+
188
+ Expected output (abridged):
189
+
190
+ ```text
191
+ [*] Loading bundle: .../trust_bundle_2025-11.json
192
+ schema=crovia_trust_bundle.v1 period=2025-11
193
+
194
+ === Artifact verification ===
195
+ [RESULT] Bundle OK: all declared artifacts match size and sha256.
196
+ ```
197
+
198
+ A Trust Bundle acts as a **hash-addressable evidence pack** for auditors, regulators and partners.
199
+
200
+ Full profile:
201
+
202
+ ```text
203
+ docs/CROVIA_TRUST_BUNDLE_v1.md
204
+ ```
205
+
206
+ ---
207
+
208
+ # 4. Validation, AI Act & Evidence Tools
209
+
210
+ The open-core engine includes transparent validation and compliance modules for auditors, researchers and model-card workflows.
211
+
212
+ ## 4.1 Schema & QA Validation — `crovia_validate.py`
213
+
214
+ Validates `royalty_receipt.v1` NDJSON files:
215
+
216
+ * schema correctness
217
+ * share ≈ 1.0 checks
218
+ * rank ordering
219
+ * malformed / suspicious rows
220
+
221
+ Produces:
222
+
223
+ * validation report (Markdown)
224
+ * sample failing rows
225
+
226
+ Example:
227
+
228
+ ```bash
229
+ python crovia_validate.py data/royalty.ndjson \
230
+ --out-md docs/VALIDATE_report.md \
231
+ --out-bad data/royalty_bad_sample.ndjson
232
+ ```
233
+
234
+ Outputs:
235
+
236
+ ```text
237
+ docs/VALIDATE_*.md
238
+ data/*_bad_sample.ndjson
239
+ ```
240
+
241
+ ---
242
+
243
+ ## 4.2 AI Act Annex IV Helpers — `compliance_ai_act.py`
244
+
245
+ Generates lightweight Annex-IV-style documentation:
246
+
247
+ * provider & shard distribution
248
+ * provenance hints
249
+ * concentration & risk signals
250
+ * gaps file (`*_gaps.ndjson`)
251
+ * JSON compliance pack
252
+
253
+ Run:
254
+
255
+ ```bash
256
+ python compliance_ai_act.py data/royalty.ndjson \
257
+ --out-summary docs/AI_ACT_summary.md \
258
+ --out-gaps data/AI_ACT_gaps.ndjson \
259
+ --out-pack data/AI_ACT_pack.json
260
+ ```
261
+
262
+ ---
263
+
264
+ ## 4.3 CCL Validation — `tools/ccl_validate.py`
265
+
266
+ Validates CCL v1.1 JSON descriptors for:
267
+
268
+ * AI models
269
+ * datasets
270
+ * RAG indices
271
+ * APIs / tools
272
+
273
+ Run:
274
+
275
+ ```bash
276
+ python tools/ccl_validate.py my_model.ccl.json
277
+ ```
278
+
279
+ Full CCL spec:
280
+
281
+ ```text
282
+ docs/CROVIA_CCL_v1.1.md
283
+ ```
284
+
285
+
286
+ ## 4.4 CEP Evidence Protocol v1 — `crovia_generate_cep.py`
287
+
288
+ CROVIA CEP.v1 is a compact, verifiable evidence block for:
289
+
290
+ * Hugging Face model cards
291
+ * research papers
292
+ * audit packs
293
+ * trust bundle metadata
294
+
295
+ Generated via:
296
+
297
+ ```bash
298
+ python tools/crovia_generate_cep.py \
299
+ --trust-bundle trust_bundle.json \
300
+ --period 2025-11 \
301
+ --receipts data/royalty.ndjson \
302
+ --payouts data/payouts.csv \
303
+ --hashchain proofs/hashchain_*.txt \
304
+ --engine-version demo-2025 \
305
+ --output-format yaml
306
+ ```
307
+
308
+ The result includes:
309
+
310
+ * SHA-256 of receipts / payouts / bundle
311
+ * hash-chain root
312
+ * trust metrics (avg_top1_share, DP epsilon range, CI indicators)
313
+ * generation metadata
314
+
315
+ Full spec:
316
+
317
+
318
+ docs/CROVIA_CEP_v1.md
319
+
320
+
321
+
322
+
323
+ # 5. Status & scope
324
+
325
+ This repository is:
326
+
327
+ * **Open-core** — attribution → trust → payouts → floors → proofs
328
+ * **Demo-grade** — synthetic data
329
+ * **Evidence-first** — built for transparency, auditability, reproducibility
330
+
331
+ Business logic, contracts, billing, CCT-attested tokens and settlement overrides live in the **private PRO engine**, not here.
332
+
333
+
334
+
335
+ # 6. Licensing
336
+
337
+ Apache License 2.0
338
+
339
+ Permitted:
340
+
341
+ * commercial or academic usage
342
+ * modification and redistribution
343
+ * closed or open derivatives
344
+ * integration into external pipelines
345
+
346
+ See the `LICENSE` file.
347
+
348
+
349
+
350
+ # 7. Copyright
351
+
352
+ © 2025 — **Tarik En Nakhai**
353
+ Crovia Core Engine
354
+
355
+ This repository includes a `NOTICE` file (Apache-2.0 requirement).
356
+
357
+
358
+
359
+ # 8. Contact
360
+
361
+
362
+ info@croviatrust.com
363
+
364
+ https://croviatrust.com
365
+
366
+
367
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
368
+ =======
369
+ >>>>>>> 394d7a4 (Spider: add real GSM8K evidence run (spider_receipt.v1))