comuvia 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.
- comuvia-0.1.0/CHANGELOG.md +15 -0
- comuvia-0.1.0/LICENSE +202 -0
- comuvia-0.1.0/PKG-INFO +126 -0
- comuvia-0.1.0/README.md +101 -0
- comuvia-0.1.0/pyproject.toml +46 -0
- comuvia-0.1.0/src/comuvia/__init__.py +73 -0
- comuvia-0.1.0/src/comuvia/__main__.py +7 -0
- comuvia-0.1.0/src/comuvia/cli.py +343 -0
- comuvia-0.1.0/src/comuvia/evaluation.py +325 -0
- comuvia-0.1.0/src/comuvia/history.py +15 -0
- comuvia-0.1.0/src/comuvia/identity.py +413 -0
- comuvia-0.1.0/src/comuvia/issues.py +31 -0
- comuvia-0.1.0/src/comuvia/reasons.py +132 -0
- comuvia-0.1.0/src/comuvia/rules/binary-brier-v1/1.json +1 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/artifact_descriptor.json +194 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/assessment.json +166 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/common.json +296 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/evaluation.json +186 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/forecast.json +202 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/interpretation.json +153 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/outcome.json +207 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/question.json +191 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/resource_snapshot.json +227 -0
- comuvia-0.1.0/src/comuvia/schemas/v0_1/source_assertion.json +272 -0
- comuvia-0.1.0/src/comuvia/selectors.py +70 -0
- comuvia-0.1.0/src/comuvia/store.py +499 -0
- comuvia-0.1.0/src/comuvia/validation.py +452 -0
- comuvia-0.1.0/tests/test_conformance.py +165 -0
- comuvia-0.1.0/tests/test_end_to_end.py +188 -0
- comuvia-0.1.0/tests/test_installed.py +26 -0
- comuvia-0.1.0/tests/test_store.py +270 -0
- comuvia-0.1.0/tests/test_vectors.py +296 -0
- comuvia-0.1.0/tests/vectors/canonicalization.json +628 -0
- comuvia-0.1.0/tests/vectors/evaluation.json +5007 -0
- comuvia-0.1.0/tests/vectors/identity.json +1137 -0
- comuvia-0.1.0/tests/vectors/records.json +1105 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# comuvia changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — release candidate (not yet published)
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
- **Records.** Nine `comuvia/0.1` record types with packaged JSON Schemas: `resource_snapshot`, `source_assertion`, `interpretation`, `assessment`, `question`, `forecast`, `outcome`, `evaluation` and `artifact_descriptor`. Unknown and withheld markers, day-precision values, required `limitations` codes, and namespaced `extensions`.
|
|
8
|
+
- **Strict parsing and validation** with named refusal codes, including a fixed nesting limit of 64 and refusal of integer literals that binary64 would change.
|
|
9
|
+
- **Identity.** RFC 8785 canonicalization (in-repository encoder, checked against the RFC's examples and an independent implementation), SHA-256 record and content digests, references that carry digests, `verify`, `revision_conflicts` and `check_selector`.
|
|
10
|
+
- **Store.** `RecordStore`: single writer (an OS lock on a persistent `writer.lock`), append-only, crash-safe appends, a read-time latest view, and `verify`, which reports each problem by name and states the checkpoint detection limit.
|
|
11
|
+
- **Evaluation.** The packaged `binary-brier-v1` rule descriptor, version `1`, pinned by digest. Every failing eligibility check is reported, including unknown question members, indeterminate day-precision order and limitation exclusions. There is no aggregate score. `evaluation_records` and `reproduce` are included.
|
|
12
|
+
- **CLI.** The `comuvia` console script, with `--json` and exit codes 0/1/2, and no network command.
|
|
13
|
+
- **No runtime dependencies.** Apache-2.0.
|
|
14
|
+
|
|
15
|
+
Pre-release development versions (`0.1.0.dev0`) and their scoring-rule descriptors are not supported. An evaluation that pins a pre-release rule digest reproduces as `unavailable` (`rule_not_found`).
|
comuvia-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
comuvia-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: comuvia
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline, provider-neutral evidence and prediction records: validation, canonical identity, append-only storage and binary evaluation.
|
|
5
|
+
Keywords: forecasting,provenance,evidence,brier,canonical-json
|
|
6
|
+
Author: Comuvia
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Project-URL: Documentation, https://github.com/comuvia/comuvia-sdk/tree/main/documentation/tutorials
|
|
22
|
+
Project-URL: Issues, https://github.com/comuvia/comuvia-sdk/issues
|
|
23
|
+
Project-URL: Repository, https://github.com/comuvia/comuvia-sdk
|
|
24
|
+
|
|
25
|
+
# comuvia
|
|
26
|
+
|
|
27
|
+
`comuvia` is an offline, provider-neutral library for evidence and prediction records. It keeps exact source bytes separate from record identity. Statements, interpretations, assessments and declared probabilities are distinct record types, and a missing value stays explicitly unknown or withheld. Only explicitly eligible structured forecasts are scored; every other candidate is reported with named exclusion reasons.
|
|
28
|
+
|
|
29
|
+
Version 0.1.0 · Apache-2.0 · Python 3.11–3.13 · no runtime dependencies · no network access.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pip install comuvia
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This installs the `comuvia` library and the `comuvia` command. There are no dependencies.
|
|
38
|
+
|
|
39
|
+
## First steps
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import comuvia
|
|
43
|
+
|
|
44
|
+
# Strict parsing refuses ambiguous JSON, by name.
|
|
45
|
+
try:
|
|
46
|
+
comuvia.parse_json(b'{"p": 0.7, "p": 0.3}')
|
|
47
|
+
except comuvia.RefusalError as refusal:
|
|
48
|
+
print(sorted(refusal.codes)) # ['duplicate_member']
|
|
49
|
+
|
|
50
|
+
# Identity is SHA-256 over RFC 8785 canonical bytes.
|
|
51
|
+
body = comuvia.parse_json('{"b": 1.0, "a": "synthetic"}')
|
|
52
|
+
print(comuvia.canonicalize(body)) # b'{"a":"synthetic","b":1}'
|
|
53
|
+
print(comuvia.record_digest(body)) # sha256:cc77f650...
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
To score a forecast, take the synthetic records from the [source repository](https://github.com/comuvia/comuvia-sdk) and run this from its root:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
git clone https://github.com/comuvia/comuvia-sdk
|
|
60
|
+
cd comuvia-sdk
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import pathlib
|
|
65
|
+
import comuvia
|
|
66
|
+
|
|
67
|
+
folder = pathlib.Path("fixtures/synthetic/structured-binary/records")
|
|
68
|
+
records = [comuvia.load_record(path.read_bytes()) for path in sorted(folder.glob("*.json"))]
|
|
69
|
+
report = comuvia.evaluate(records)
|
|
70
|
+
(result,) = report.results
|
|
71
|
+
print(result.status, result.loss) # scored 0.09000000000000002
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Tutorials
|
|
75
|
+
|
|
76
|
+
Two offline tutorials walk through the API and the `comuvia` command. Each has a script that checks every value the page states:
|
|
77
|
+
|
|
78
|
+
- [A: a source-linked statement, honestly excluded](https://github.com/comuvia/comuvia-sdk/blob/main/documentation/tutorials/A-source-linked-statement.md): `python documentation/tutorials/tutorial_a_narrative.py --fixtures fixtures/synthetic --work ./tutorial-a`
|
|
79
|
+
- [B: a declared-probability forecast, its outcome and a correction](https://github.com/comuvia/comuvia-sdk/blob/main/documentation/tutorials/B-declared-probability-forecast.md): `python documentation/tutorials/tutorial_b_forecast.py --fixtures fixtures/synthetic --work ./tutorial-b`
|
|
80
|
+
|
|
81
|
+
Run them from the repository root. Every person, organisation and value in the [fixtures](https://github.com/comuvia/comuvia-sdk/tree/main/fixtures/synthetic) is fictional.
|
|
82
|
+
|
|
83
|
+
## Capabilities
|
|
84
|
+
|
|
85
|
+
| Capability | What it does | API | CLI |
|
|
86
|
+
|---|---|---|---|
|
|
87
|
+
| Record types | Nine `comuvia/0.1` types: `resource_snapshot`, `source_assertion`, `interpretation`, `assessment`, `question`, `forecast`, `outcome`, `evaluation`, `artifact_descriptor`. JSON Schemas ship in the package | `schema_files()`, `RECORD_TYPES` | — |
|
|
88
|
+
| Strict parsing | Refuses duplicate members, invalid UTF-8, a BOM, unpaired surrogates, non-finite numbers, integers binary64 would change, and nesting deeper than 64 | `parse_json` | — |
|
|
89
|
+
| Validation | Refusals with named codes and JSON Pointers; unknown and withheld markers; day-precision values; namespaced `extensions` | `validate`, `load_record` | `comuvia validate` |
|
|
90
|
+
| Identity | RFC 8785 canonical bytes; SHA-256 record and content digests; references that carry digests; separate record, content and reference results | `canonicalize`, `record_digest`, `content_digest`, `reference_to`, `verify`, `revision_conflicts` | `comuvia digest`, `comuvia verify` |
|
|
91
|
+
| Selector check | A verbatim quote, its prefix/suffix and its code-point position, checked against retained bytes | `check_selector` | `comuvia verify --content` |
|
|
92
|
+
| Record store | Single writer, append-only, crash-safe; corrections are successor revisions; a "latest" view derived at read time; `verify` names each problem | `RecordStore` | `comuvia store init/append/verify/show/repair` |
|
|
93
|
+
| Evaluation | The packaged `binary-brier-v1` rule: every failing eligibility check named, all counts shown, raw binary64 losses, **no aggregate score** | `evaluate`, `load_rule` | `comuvia evaluate` |
|
|
94
|
+
| Reproduction | Re-derives a stored evaluation from the forecast, outcome and rule it pins by digest | `evaluation_records`, `reproduce` | `comuvia evaluate --append`, `comuvia reproduce` |
|
|
95
|
+
|
|
96
|
+
## What 0.1.0 promises
|
|
97
|
+
|
|
98
|
+
- **Record shapes.** The `comuvia/0.1` shapes are frozen: the packaged schemas, and the record digest (SHA-256 over RFC 8785 bytes of the whole body). Any change is a new schema version.
|
|
99
|
+
- **Scoring rule.** `binary-brier-v1` version `1`, `sha256:9a0180cf0678614b3d423ca8e641bff9805e8582ce898438d8586251f96877c1`. A changed rule is a new version; a stored evaluation pins its rule by digest.
|
|
100
|
+
- **Names.** The names in `comuvia.__all__` and the reason-code strings in `comuvia.reasons`.
|
|
101
|
+
- **Exit codes.** The CLI exit codes: 0 success (exclusions are results, not errors), 1 refusal or mismatch, 2 usage error.
|
|
102
|
+
- **Store format.** The store directory format `comuvia-store/1`.
|
|
103
|
+
|
|
104
|
+
**Provisional in 0.1.0:** the CLI's human-readable output and the layout of its `--json` output, and the wording of issue messages. Reason *codes* are stable; message *text* is not.
|
|
105
|
+
|
|
106
|
+
## Limitations
|
|
107
|
+
|
|
108
|
+
- **Store detection limit.** `store verify` cannot detect removal of complete index lines at the end, or replacement of a whole store, without an independently retained checkpoint. Checkpoints are not in 0.1.0.
|
|
109
|
+
- **Lock scope.** The writer lock is an operating-system lock on `writer.lock`. It coordinates `comuvia` processes on one machine and is not tested on network file systems. Readers never lock.
|
|
110
|
+
- **Share exported records, not a store directory.** `writer.lock` holds the current or last writer's pid, host name and time. Share or publish records as record files, for example via `comuvia store show --json --bodies`, not by copying a raw store directory.
|
|
111
|
+
- **Day-precision ordering.** A value known only to the day may be any instant of that date at UTC offsets −12:00 to +14:00. Its order against a timestamp inside that window is reported as indeterminate (`indeterminate_time_order`), never guessed.
|
|
112
|
+
- **Rule scope.** 0.1.0 scores only unconditional binary forecasts with a declared probability against a resolved binary outcome. There are no interval, point or conditional scorers, and no aggregate, skill or relative scores.
|
|
113
|
+
- **Locators.** They are recorded for provenance and never dereferenced. Locators with userinfo credentials are refused, but tokens in query strings (signed URLs) cannot be detected in general: **do not record secret or signed locators.**
|
|
114
|
+
- **What a digest proves.** Byte or record identity only. It does not prove truth, authorship or publication time. Timestamp assurance is always reported as `unavailable`, and signatures and proofs are not part of 0.1.0.
|
|
115
|
+
- **Scope of `store verify`.** It checks identity, not evaluation correctness. Run `reproduce` for any stored evaluation you rely on.
|
|
116
|
+
|
|
117
|
+
## Tests
|
|
118
|
+
|
|
119
|
+
The `tests/` directory in the source distribution checks an installed wheel against language-neutral vectors in `tests/vectors/`. Run it with `python -m unittest discover -s tests`. The optional `jsonschema` and `rfc8785` libraries enable extra agreement checks; they are test-only.
|
|
120
|
+
|
|
121
|
+
## Source, issues and security
|
|
122
|
+
|
|
123
|
+
- Source, release checksums and build recipe: [github.com/comuvia/comuvia-sdk](https://github.com/comuvia/comuvia-sdk) ([`release/0.1.0`](https://github.com/comuvia/comuvia-sdk/tree/main/release/0.1.0))
|
|
124
|
+
- Issues: [github.com/comuvia/comuvia-sdk/issues](https://github.com/comuvia/comuvia-sdk/issues)
|
|
125
|
+
- Reporting a vulnerability: [SECURITY.md](https://github.com/comuvia/comuvia-sdk/blob/main/SECURITY.md)
|
|
126
|
+
|
comuvia-0.1.0/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# comuvia
|
|
2
|
+
|
|
3
|
+
`comuvia` is an offline, provider-neutral library for evidence and prediction records. It keeps exact source bytes separate from record identity. Statements, interpretations, assessments and declared probabilities are distinct record types, and a missing value stays explicitly unknown or withheld. Only explicitly eligible structured forecasts are scored; every other candidate is reported with named exclusion reasons.
|
|
4
|
+
|
|
5
|
+
Version 0.1.0 · Apache-2.0 · Python 3.11–3.13 · no runtime dependencies · no network access.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pip install comuvia
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This installs the `comuvia` library and the `comuvia` command. There are no dependencies.
|
|
14
|
+
|
|
15
|
+
## First steps
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import comuvia
|
|
19
|
+
|
|
20
|
+
# Strict parsing refuses ambiguous JSON, by name.
|
|
21
|
+
try:
|
|
22
|
+
comuvia.parse_json(b'{"p": 0.7, "p": 0.3}')
|
|
23
|
+
except comuvia.RefusalError as refusal:
|
|
24
|
+
print(sorted(refusal.codes)) # ['duplicate_member']
|
|
25
|
+
|
|
26
|
+
# Identity is SHA-256 over RFC 8785 canonical bytes.
|
|
27
|
+
body = comuvia.parse_json('{"b": 1.0, "a": "synthetic"}')
|
|
28
|
+
print(comuvia.canonicalize(body)) # b'{"a":"synthetic","b":1}'
|
|
29
|
+
print(comuvia.record_digest(body)) # sha256:cc77f650...
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To score a forecast, take the synthetic records from the [source repository](https://github.com/comuvia/comuvia-sdk) and run this from its root:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
git clone https://github.com/comuvia/comuvia-sdk
|
|
36
|
+
cd comuvia-sdk
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import pathlib
|
|
41
|
+
import comuvia
|
|
42
|
+
|
|
43
|
+
folder = pathlib.Path("fixtures/synthetic/structured-binary/records")
|
|
44
|
+
records = [comuvia.load_record(path.read_bytes()) for path in sorted(folder.glob("*.json"))]
|
|
45
|
+
report = comuvia.evaluate(records)
|
|
46
|
+
(result,) = report.results
|
|
47
|
+
print(result.status, result.loss) # scored 0.09000000000000002
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Tutorials
|
|
51
|
+
|
|
52
|
+
Two offline tutorials walk through the API and the `comuvia` command. Each has a script that checks every value the page states:
|
|
53
|
+
|
|
54
|
+
- [A: a source-linked statement, honestly excluded](https://github.com/comuvia/comuvia-sdk/blob/main/documentation/tutorials/A-source-linked-statement.md): `python documentation/tutorials/tutorial_a_narrative.py --fixtures fixtures/synthetic --work ./tutorial-a`
|
|
55
|
+
- [B: a declared-probability forecast, its outcome and a correction](https://github.com/comuvia/comuvia-sdk/blob/main/documentation/tutorials/B-declared-probability-forecast.md): `python documentation/tutorials/tutorial_b_forecast.py --fixtures fixtures/synthetic --work ./tutorial-b`
|
|
56
|
+
|
|
57
|
+
Run them from the repository root. Every person, organisation and value in the [fixtures](https://github.com/comuvia/comuvia-sdk/tree/main/fixtures/synthetic) is fictional.
|
|
58
|
+
|
|
59
|
+
## Capabilities
|
|
60
|
+
|
|
61
|
+
| Capability | What it does | API | CLI |
|
|
62
|
+
|---|---|---|---|
|
|
63
|
+
| Record types | Nine `comuvia/0.1` types: `resource_snapshot`, `source_assertion`, `interpretation`, `assessment`, `question`, `forecast`, `outcome`, `evaluation`, `artifact_descriptor`. JSON Schemas ship in the package | `schema_files()`, `RECORD_TYPES` | — |
|
|
64
|
+
| Strict parsing | Refuses duplicate members, invalid UTF-8, a BOM, unpaired surrogates, non-finite numbers, integers binary64 would change, and nesting deeper than 64 | `parse_json` | — |
|
|
65
|
+
| Validation | Refusals with named codes and JSON Pointers; unknown and withheld markers; day-precision values; namespaced `extensions` | `validate`, `load_record` | `comuvia validate` |
|
|
66
|
+
| Identity | RFC 8785 canonical bytes; SHA-256 record and content digests; references that carry digests; separate record, content and reference results | `canonicalize`, `record_digest`, `content_digest`, `reference_to`, `verify`, `revision_conflicts` | `comuvia digest`, `comuvia verify` |
|
|
67
|
+
| Selector check | A verbatim quote, its prefix/suffix and its code-point position, checked against retained bytes | `check_selector` | `comuvia verify --content` |
|
|
68
|
+
| Record store | Single writer, append-only, crash-safe; corrections are successor revisions; a "latest" view derived at read time; `verify` names each problem | `RecordStore` | `comuvia store init/append/verify/show/repair` |
|
|
69
|
+
| Evaluation | The packaged `binary-brier-v1` rule: every failing eligibility check named, all counts shown, raw binary64 losses, **no aggregate score** | `evaluate`, `load_rule` | `comuvia evaluate` |
|
|
70
|
+
| Reproduction | Re-derives a stored evaluation from the forecast, outcome and rule it pins by digest | `evaluation_records`, `reproduce` | `comuvia evaluate --append`, `comuvia reproduce` |
|
|
71
|
+
|
|
72
|
+
## What 0.1.0 promises
|
|
73
|
+
|
|
74
|
+
- **Record shapes.** The `comuvia/0.1` shapes are frozen: the packaged schemas, and the record digest (SHA-256 over RFC 8785 bytes of the whole body). Any change is a new schema version.
|
|
75
|
+
- **Scoring rule.** `binary-brier-v1` version `1`, `sha256:9a0180cf0678614b3d423ca8e641bff9805e8582ce898438d8586251f96877c1`. A changed rule is a new version; a stored evaluation pins its rule by digest.
|
|
76
|
+
- **Names.** The names in `comuvia.__all__` and the reason-code strings in `comuvia.reasons`.
|
|
77
|
+
- **Exit codes.** The CLI exit codes: 0 success (exclusions are results, not errors), 1 refusal or mismatch, 2 usage error.
|
|
78
|
+
- **Store format.** The store directory format `comuvia-store/1`.
|
|
79
|
+
|
|
80
|
+
**Provisional in 0.1.0:** the CLI's human-readable output and the layout of its `--json` output, and the wording of issue messages. Reason *codes* are stable; message *text* is not.
|
|
81
|
+
|
|
82
|
+
## Limitations
|
|
83
|
+
|
|
84
|
+
- **Store detection limit.** `store verify` cannot detect removal of complete index lines at the end, or replacement of a whole store, without an independently retained checkpoint. Checkpoints are not in 0.1.0.
|
|
85
|
+
- **Lock scope.** The writer lock is an operating-system lock on `writer.lock`. It coordinates `comuvia` processes on one machine and is not tested on network file systems. Readers never lock.
|
|
86
|
+
- **Share exported records, not a store directory.** `writer.lock` holds the current or last writer's pid, host name and time. Share or publish records as record files, for example via `comuvia store show --json --bodies`, not by copying a raw store directory.
|
|
87
|
+
- **Day-precision ordering.** A value known only to the day may be any instant of that date at UTC offsets −12:00 to +14:00. Its order against a timestamp inside that window is reported as indeterminate (`indeterminate_time_order`), never guessed.
|
|
88
|
+
- **Rule scope.** 0.1.0 scores only unconditional binary forecasts with a declared probability against a resolved binary outcome. There are no interval, point or conditional scorers, and no aggregate, skill or relative scores.
|
|
89
|
+
- **Locators.** They are recorded for provenance and never dereferenced. Locators with userinfo credentials are refused, but tokens in query strings (signed URLs) cannot be detected in general: **do not record secret or signed locators.**
|
|
90
|
+
- **What a digest proves.** Byte or record identity only. It does not prove truth, authorship or publication time. Timestamp assurance is always reported as `unavailable`, and signatures and proofs are not part of 0.1.0.
|
|
91
|
+
- **Scope of `store verify`.** It checks identity, not evaluation correctness. Run `reproduce` for any stored evaluation you rely on.
|
|
92
|
+
|
|
93
|
+
## Tests
|
|
94
|
+
|
|
95
|
+
The `tests/` directory in the source distribution checks an installed wheel against language-neutral vectors in `tests/vectors/`. Run it with `python -m unittest discover -s tests`. The optional `jsonschema` and `rfc8785` libraries enable extra agreement checks; they are test-only.
|
|
96
|
+
|
|
97
|
+
## Source, issues and security
|
|
98
|
+
|
|
99
|
+
- Source, release checksums and build recipe: [github.com/comuvia/comuvia-sdk](https://github.com/comuvia/comuvia-sdk) ([`release/0.1.0`](https://github.com/comuvia/comuvia-sdk/tree/main/release/0.1.0))
|
|
100
|
+
- Issues: [github.com/comuvia/comuvia-sdk/issues](https://github.com/comuvia/comuvia-sdk/issues)
|
|
101
|
+
- Reporting a vulnerability: [SECURITY.md](https://github.com/comuvia/comuvia-sdk/blob/main/SECURITY.md)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["flit_core>=3.12,<4"]
|
|
3
|
+
build-backend = "flit_core.buildapi"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "comuvia"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Offline, provider-neutral evidence and prediction records: validation, canonical identity, append-only storage and binary evaluation."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
dependencies = []
|
|
12
|
+
license = "Apache-2.0"
|
|
13
|
+
license-files = ["LICENSE"]
|
|
14
|
+
authors = [{ name = "Comuvia" }]
|
|
15
|
+
keywords = ["forecasting", "provenance", "evidence", "brier", "canonical-json"]
|
|
16
|
+
# Python version classifiers name only versions measured on the release matrix
|
|
17
|
+
# (CPython 3.11, 3.12 and 3.13 on Windows x86-64 and Linux x86-64).
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Intended Audience :: Science/Research",
|
|
22
|
+
"Operating System :: Microsoft :: Windows",
|
|
23
|
+
"Operating System :: POSIX :: Linux",
|
|
24
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Repository = "https://github.com/comuvia/comuvia-sdk"
|
|
33
|
+
Documentation = "https://github.com/comuvia/comuvia-sdk/tree/main/documentation/tutorials"
|
|
34
|
+
Issues = "https://github.com/comuvia/comuvia-sdk/issues"
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
comuvia = "comuvia.cli:main"
|
|
38
|
+
|
|
39
|
+
[tool.flit.module]
|
|
40
|
+
name = "comuvia"
|
|
41
|
+
|
|
42
|
+
# Distribution contents are listed explicitly; Git ignore rules are not a packaging boundary.
|
|
43
|
+
# The wheel holds only src/comuvia; the sdist adds pyproject.toml, README.md, PKG-INFO and these paths.
|
|
44
|
+
[tool.flit.sdist]
|
|
45
|
+
include = ["tests/", "CHANGELOG.md"]
|
|
46
|
+
exclude = ["**/__pycache__", "**/*.py[cod]"]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Comuvia: offline, provider-neutral evidence and prediction records.
|
|
2
|
+
|
|
3
|
+
Implemented: the nine comuvia 0.1 record types as packaged JSON Schemas, strict parsing,
|
|
4
|
+
single-record validation with named refusal codes, RFC 8785 canonicalization, content and
|
|
5
|
+
record digests, identity and selector verification, a single-writer append-only record
|
|
6
|
+
store, eligibility and the binary-brier-v1 rule with named exclusions, reproduction of
|
|
7
|
+
stored evaluations, and the ``comuvia`` command-line interface. There is no aggregate
|
|
8
|
+
score, no network access and no runtime dependency.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0"
|
|
12
|
+
|
|
13
|
+
from .identity import (
|
|
14
|
+
ReferenceCheck,
|
|
15
|
+
Verification,
|
|
16
|
+
canonicalize,
|
|
17
|
+
content_digest,
|
|
18
|
+
is_marker,
|
|
19
|
+
parse_json,
|
|
20
|
+
record_digest,
|
|
21
|
+
reference_to,
|
|
22
|
+
revision_conflicts,
|
|
23
|
+
verify,
|
|
24
|
+
)
|
|
25
|
+
from .evaluation import (
|
|
26
|
+
CandidateResult,
|
|
27
|
+
EvaluationReport,
|
|
28
|
+
Reproduction,
|
|
29
|
+
ScoringRule,
|
|
30
|
+
evaluate,
|
|
31
|
+
evaluation_records,
|
|
32
|
+
load_rule,
|
|
33
|
+
reproduce,
|
|
34
|
+
)
|
|
35
|
+
from .history import latest_revisions
|
|
36
|
+
from .issues import Issue, RefusalError
|
|
37
|
+
from .selectors import SelectorCheck, check_selector
|
|
38
|
+
from .store import RecordStore, StoreEntry, StoreReport
|
|
39
|
+
from .validation import RECORD_TYPES, SCHEMA_VERSION, load_record, schema_files, validate
|
|
40
|
+
|
|
41
|
+
__all__ = [
|
|
42
|
+
"CandidateResult",
|
|
43
|
+
"EvaluationReport",
|
|
44
|
+
"Issue",
|
|
45
|
+
"RECORD_TYPES",
|
|
46
|
+
"RecordStore",
|
|
47
|
+
"ReferenceCheck",
|
|
48
|
+
"RefusalError",
|
|
49
|
+
"Reproduction",
|
|
50
|
+
"SCHEMA_VERSION",
|
|
51
|
+
"ScoringRule",
|
|
52
|
+
"SelectorCheck",
|
|
53
|
+
"StoreEntry",
|
|
54
|
+
"StoreReport",
|
|
55
|
+
"Verification",
|
|
56
|
+
"canonicalize",
|
|
57
|
+
"check_selector",
|
|
58
|
+
"content_digest",
|
|
59
|
+
"evaluate",
|
|
60
|
+
"evaluation_records",
|
|
61
|
+
"is_marker",
|
|
62
|
+
"latest_revisions",
|
|
63
|
+
"load_record",
|
|
64
|
+
"load_rule",
|
|
65
|
+
"parse_json",
|
|
66
|
+
"record_digest",
|
|
67
|
+
"reference_to",
|
|
68
|
+
"reproduce",
|
|
69
|
+
"revision_conflicts",
|
|
70
|
+
"schema_files",
|
|
71
|
+
"validate",
|
|
72
|
+
"verify",
|
|
73
|
+
]
|