bioai-evidence-validator 0.4.1__py3-none-any.whl
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.
- bioai_evidence_validator-0.4.1.dist-info/METADATA +241 -0
- bioai_evidence_validator-0.4.1.dist-info/RECORD +13 -0
- bioai_evidence_validator-0.4.1.dist-info/WHEEL +4 -0
- bioai_evidence_validator-0.4.1.dist-info/entry_points.txt +2 -0
- bioai_evidence_validator-0.4.1.dist-info/licenses/LICENSE +202 -0
- bioevidence_validator/__init__.py +3 -0
- bioevidence_validator/cli.py +114 -0
- bioevidence_validator/config.py +37 -0
- bioevidence_validator/engine.py +265 -0
- bioevidence_validator/profiles/dataset-label.yaml +35 -0
- bioevidence_validator/profiles/general.yaml +28 -0
- bioevidence_validator/profiles/literature-claim.yaml +26 -0
- bioevidence_validator/schema/bioevidence_core.yaml +336 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: bioai-evidence-validator
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Standards-aligned evidence policy validation for AI-assisted biological curation
|
|
5
|
+
Project-URL: Homepage, https://github.com/NingyuSUN/bioai-evidence-validator
|
|
6
|
+
Project-URL: Documentation, https://github.com/NingyuSUN/bioai-evidence-validator/tree/main/docs
|
|
7
|
+
Project-URL: Changelog, https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/CHANGELOG.md
|
|
8
|
+
Project-URL: Issues, https://github.com/NingyuSUN/bioai-evidence-validator/issues
|
|
9
|
+
Author: Ningyu Sun
|
|
10
|
+
License: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai-safety,biocuration,bioinformatics,evidence,knowledge-graph,linkml,llm,ontology,provenance,validation
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: jsonschema<5,>=4.23
|
|
25
|
+
Requires-Dist: linkml<2,>=1.8
|
|
26
|
+
Requires-Dist: pyyaml<7,>=6.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest<9,>=8; extra == 'dev'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# BioAI Evidence Validator
|
|
32
|
+
|
|
33
|
+
[](https://github.com/NingyuSUN/bioai-evidence-validator/actions/workflows/ci.yml)
|
|
34
|
+
[](https://pypi.org/project/bioai-evidence-validator/)
|
|
35
|
+
[](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/pyproject.toml)
|
|
36
|
+
[](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/LICENSE)
|
|
37
|
+
|
|
38
|
+
**Stop AI-extracted biological claims from entering your knowledge base or
|
|
39
|
+
training set before their evidence is good enough for that use.**
|
|
40
|
+
|
|
41
|
+
An LLM can turn a paper into a tidy `gene → associated_with → phenotype` record
|
|
42
|
+
that passes every schema check. This toolkit asks the next question: *is the
|
|
43
|
+
evidence behind it sufficient for the specific use you have in mind?* It checks
|
|
44
|
+
evidence structure, provenance consistency, scope and human-review requirements,
|
|
45
|
+
then returns an auditable **admitted / review_required / rejected** decision for
|
|
46
|
+
each requested use.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install bioai-evidence-validator
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 30-second example
|
|
53
|
+
|
|
54
|
+
The two records below are identical except for one field: how the supporting
|
|
55
|
+
evidence was extracted.
|
|
56
|
+
|
|
57
|
+
```diff
|
|
58
|
+
"evidence_type": "publication_result",
|
|
59
|
+
- "extraction_method": "llm_extraction",
|
|
60
|
+
+ "extraction_method": "manual_curation",
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```console
|
|
64
|
+
$ bioevidence validate examples/literature_claim/llm_only.json --profile literature-claim
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"overall_status": "review_required",
|
|
70
|
+
"findings": [
|
|
71
|
+
{
|
|
72
|
+
"rule_id": "BEV008",
|
|
73
|
+
"severity": "review",
|
|
74
|
+
"message": "Required evidence type 'publication_result' comes only from LLM extraction.",
|
|
75
|
+
"blocking_uses": ["research_summary"]
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"use_decisions": [
|
|
79
|
+
{ "use": "research_summary", "admission_status": "review_required", "reason_codes": ["BEV008"] }
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The command exits with **2**, so a pipeline can route the record to a reviewer.
|
|
85
|
+
The manually curated version (`examples/literature_claim/curated_association.json`)
|
|
86
|
+
is `admitted` with exit code **0**. Every full report also records the input,
|
|
87
|
+
schema and profile SHA-256 hashes and versions for audit.
|
|
88
|
+
|
|
89
|
+
## Why not just JSON Schema or Pydantic?
|
|
90
|
+
|
|
91
|
+
A schema tells you a record is well formed. It cannot tell you whether the
|
|
92
|
+
record is trustworthy enough for a particular purpose.
|
|
93
|
+
|
|
94
|
+
| | Schema validation | This validator |
|
|
95
|
+
|---|:---:|:---:|
|
|
96
|
+
| Record shape and types | ✅ | ✅ (LinkML) |
|
|
97
|
+
| Different evidence rules per intended use (summary vs. KB vs. training) | — | ✅ |
|
|
98
|
+
| Quality gate per required evidence type (LLM-only evidence cannot ride on unrelated manual evidence) | — | ✅ |
|
|
99
|
+
| Provenance consistency (source hashes, resolved references, scope) | — | ✅ |
|
|
100
|
+
| Human adjudications bound to a specific statement and use | — | ✅ |
|
|
101
|
+
| Machine-readable audit report with hashes of input, schema and profile | — | ✅ |
|
|
102
|
+
|
|
103
|
+
On the real-data benchmark below, schema-only checks admitted **160/160**
|
|
104
|
+
injected faults; the full validator admitted **0/160**.
|
|
105
|
+
|
|
106
|
+
## Use it
|
|
107
|
+
|
|
108
|
+
### Command line
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
bioevidence profiles # list built-in profiles and their use contracts
|
|
112
|
+
bioevidence validate record.json --profile literature-claim
|
|
113
|
+
bioevidence validate record.json --profile my_profile.yaml --output report.json
|
|
114
|
+
bioevidence generate-schema --output record.schema.json # JSON Schema for the input format
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Exit codes: **0** admitted, **1** rejected, **2** review required, **3** input or configuration error.
|
|
118
|
+
|
|
119
|
+
### Python
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
import json
|
|
123
|
+
from pathlib import Path
|
|
124
|
+
|
|
125
|
+
from bioevidence_validator.engine import validate_record
|
|
126
|
+
|
|
127
|
+
record = json.loads(Path("record.json").read_text(encoding="utf-8"))
|
|
128
|
+
report = validate_record(record, profile="literature-claim")
|
|
129
|
+
|
|
130
|
+
for decision in report["use_decisions"]:
|
|
131
|
+
print(decision["use"], decision["admission_status"], decision["reason_codes"])
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`profile` accepts a built-in name or a path to your own YAML profile.
|
|
135
|
+
|
|
136
|
+
## How it works
|
|
137
|
+
|
|
138
|
+
```mermaid
|
|
139
|
+
flowchart TD
|
|
140
|
+
A["Structured evidence JSON"] --> B["LinkML structure checks"]
|
|
141
|
+
B --> C["Reference and scope checks"]
|
|
142
|
+
P["Selected YAML profile"] --> C
|
|
143
|
+
C --> D["Evidence and human review requirements"]
|
|
144
|
+
D --> E["Decision for each requested use"]
|
|
145
|
+
E --> F["Audit report: findings, versions and hashes"]
|
|
146
|
+
S["Frozen source evidence + intended use"] --> R["Independent human annotation"]
|
|
147
|
+
R --> J["Resolve disagreements and record uncertainty"]
|
|
148
|
+
J --> G["Freeze gold-standard test set"]
|
|
149
|
+
G --> V["Compare held-out decisions with gold standard"]
|
|
150
|
+
F --> V
|
|
151
|
+
V --> M["False admission, false block and review rates"]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
This diagram defines the complete project workflow. Each project supplies its own
|
|
155
|
+
reviewed reference labels; the validator's decisions are evaluated against them.
|
|
156
|
+
Gold labels stay separate from runtime evidence and rule development.
|
|
157
|
+
|
|
158
|
+
Domain rules are YAML profiles: new entity types, relations, evidence types and
|
|
159
|
+
uses do not require engine edits.
|
|
160
|
+
|
|
161
|
+
| Example profile | Assertion | Use contract |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| `general` | Any typed entity–relation–entity statement | Provenance, scoped support, optional human review by use |
|
|
164
|
+
| `literature-claim` | Gene/variant associated with phenotype/disease | Publication evidence; human acceptance for knowledge-base admission |
|
|
165
|
+
| `dataset-label` | Sample assigned a label | Curated label plus sample link; human acceptance for training |
|
|
166
|
+
| Custom YAML | Compound measured response in an assay | Assay evidence; defined without changing Python code |
|
|
167
|
+
|
|
168
|
+
See [Create a profile](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/docs/PROFILES.md).
|
|
169
|
+
|
|
170
|
+
## Run the examples from source
|
|
171
|
+
|
|
172
|
+
Python 3.11+ and [uv](https://docs.astral.sh/uv/), from the repository root:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
uv sync --frozen --extra dev
|
|
176
|
+
uv run bioevidence profiles
|
|
177
|
+
uv run bioevidence validate examples/general/curated_assertion.json
|
|
178
|
+
uv run bioevidence validate examples/literature_claim/llm_only.json --profile literature-claim
|
|
179
|
+
uv run bioevidence validate examples/custom_profile/assay_record.json --profile examples/custom_profile/assay.yaml
|
|
180
|
+
uv run pytest
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Build a gold standard for your project
|
|
184
|
+
|
|
185
|
+
1. **Define the task:** specify the domain, intended uses, label definitions and evidence requirements in a written rubric.
|
|
186
|
+
2. **Select and freeze cases:** retain source versions and record hashes; group related entities and aliases into the same development/test split.
|
|
187
|
+
3. **Review independently:** domain reviewers label mapping correctness and use-specific admission without seeing validator predictions; record evidence and uncertainty.
|
|
188
|
+
4. **Resolve and version:** preserve original reviews, document disagreements and adjudication, then freeze the labels and provenance manifest.
|
|
189
|
+
5. **Evaluate:** compare held-out decisions with that reference; report false admissions, false blocks and review rates with counts and denominators.
|
|
190
|
+
|
|
191
|
+
Use the [annotation templates](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/evaluation/gold_standard/README.md) and
|
|
192
|
+
[detailed protocol](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/docs/GOLD_STANDARD.md). Each gold standard is specific to a task,
|
|
193
|
+
source version and intended use. Document reviewer roles and whether labels are
|
|
194
|
+
single-reviewed or independently reviewed by multiple people.
|
|
195
|
+
|
|
196
|
+
## Real-data case
|
|
197
|
+
|
|
198
|
+
[VBO canine name mapping](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/examples/vbo_canine/README.md) uses a frozen public ontology:
|
|
199
|
+
72 real-name cases, 160 controlled errors, and 16 separately reported trust-boundary
|
|
200
|
+
cases. It compares schema-only checks, the previous aggregate quality gate, and
|
|
201
|
+
per-required-evidence-type validation. Source-derived labels are not expert annotations.
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
uv run python examples/vbo_canine/run.py --output artifacts/vbo-canine
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Benchmark results (v0.4.1)
|
|
208
|
+
|
|
209
|
+

|
|
210
|
+
|
|
211
|
+
On 72 real-source name mappings, the full validator admitted all 48 unambiguous cases and blocked automatic admission of all 24 ambiguous names (0/48 false blocks; 0/24 false admissions). Across 160 deliberately injected faults, false admissions were 160/160 for schema-only, 64/160 for the aggregate-quality ablation, and 0/160 for the full validator; the full validator sent 80 cases to review and rejected 80. All three methods admitted 16/16 falsified-target trust-boundary cases, showing the need for trustworthy source ingestion and supplied metadata.
|
|
212
|
+
|
|
213
|
+
**Interpretation limits:** Reference labels are derived from the pinned VBO source and authored fault specifications, not independent expert annotations. The 160 mutations share 16 seed cases and are correlated. This benchmark tests the mapping contract and controlled fault detection; it does not estimate biological accuracy or production error rates. See the [protocol and full results](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/examples/vbo_canine/README.md) and [machine-readable summary](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/examples/vbo_canine/results/summary.json).
|
|
214
|
+
|
|
215
|
+
## Scope
|
|
216
|
+
|
|
217
|
+
The VBO case uses attributed public data; other fixtures are synthetic.
|
|
218
|
+
Admission means **the supplied record meets the selected
|
|
219
|
+
profile**, not that a biological claim is true. The toolkit does not retrieve papers,
|
|
220
|
+
verify reviewer identities, train models, or measure prediction accuracy. The generic core compares supplied hashes; the VBO importer also hashes its local source
|
|
221
|
+
projection. External source truth and cohort independence require upstream verification.
|
|
222
|
+
|
|
223
|
+
## Versions and branches
|
|
224
|
+
|
|
225
|
+
`main` is the domain-neutral framework (0.4.1). The complete canine implementation
|
|
226
|
+
and SQLite adapter from 0.3 live on the
|
|
227
|
+
[`canine-breed` branch](https://github.com/NingyuSUN/bioai-evidence-validator/tree/canine-breed);
|
|
228
|
+
see the [0.4 migration guide](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/docs/MIGRATION-0.4.md) and
|
|
229
|
+
[changelog](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/CHANGELOG.md).
|
|
230
|
+
|
|
231
|
+
## Citing
|
|
232
|
+
|
|
233
|
+
If you use this toolkit in research, please cite it using the metadata in
|
|
234
|
+
[`CITATION.cff`](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/CITATION.cff)
|
|
235
|
+
(GitHub's "Cite this repository" button generates APA and BibTeX).
|
|
236
|
+
|
|
237
|
+
[Create a profile](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/docs/PROFILES.md) ·
|
|
238
|
+
[Engineering contract](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/docs/ENGINEERING.md) ·
|
|
239
|
+
[Design case study](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/docs/CASE_STUDY.md) ·
|
|
240
|
+
[Architecture decision](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/docs/ADR-002-domain-neutral-main.md) ·
|
|
241
|
+
[Apache-2.0](https://github.com/NingyuSUN/bioai-evidence-validator/blob/main/LICENSE)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
bioevidence_validator/__init__.py,sha256=w-OLV_MserELKh9U9FrLM8ZICJqNoWNOlqMwglL1lIk,87
|
|
2
|
+
bioevidence_validator/cli.py,sha256=fknYldtjN50OvguGMcp_kmAky5PxZ0i5WRUF4HEQVkA,4326
|
|
3
|
+
bioevidence_validator/config.py,sha256=Ahc9eRPNR_ArqnbnJkdZsPFq9yERTYied0oGwUkANYI,1110
|
|
4
|
+
bioevidence_validator/engine.py,sha256=fm1gIOySsLiBbI3SklbEStiMD93RrhR3lA0vqdLJJXQ,15003
|
|
5
|
+
bioevidence_validator/profiles/dataset-label.yaml,sha256=4utz9YcFFF2UnaLjIb0ATb-27hF8Smw7zmv0sBTaQdM,843
|
|
6
|
+
bioevidence_validator/profiles/general.yaml,sha256=i9fJCWovJZ2e2d4rbn0Bx7mrhumNb2zjS9TOarkBWZw,778
|
|
7
|
+
bioevidence_validator/profiles/literature-claim.yaml,sha256=7l82gX3oGGyYFq9B29-1qGXeL4LRcMhJi8Y9fieVE0c,612
|
|
8
|
+
bioevidence_validator/schema/bioevidence_core.yaml,sha256=18MMngua0jlu4VnAbpb7SfI3numnCdjO986bZP6-Xn4,6700
|
|
9
|
+
bioai_evidence_validator-0.4.1.dist-info/METADATA,sha256=JkN3mmJrD-cx86fBjdrjrTaxadrM1SdzbTrtHv81uO0,12563
|
|
10
|
+
bioai_evidence_validator-0.4.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
11
|
+
bioai_evidence_validator-0.4.1.dist-info/entry_points.txt,sha256=6oufzT2x1nIhTqM5B6y4aWubExKAoFb_wXXTdz3mBQQ,63
|
|
12
|
+
bioai_evidence_validator-0.4.1.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
13
|
+
bioai_evidence_validator-0.4.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import tempfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import yaml
|
|
11
|
+
|
|
12
|
+
from .engine import default_schema_path, generate_json_schema, validate_record, profile_path, list_profiles
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def parser() -> argparse.ArgumentParser:
|
|
16
|
+
result = argparse.ArgumentParser(prog="bioevidence")
|
|
17
|
+
commands = result.add_subparsers(dest="command", required=True)
|
|
18
|
+
validate = commands.add_parser("validate", help="Validate one biological evidence record")
|
|
19
|
+
validate.add_argument("input", type=Path)
|
|
20
|
+
validate.add_argument("--output", type=Path)
|
|
21
|
+
validate.add_argument("--schema", type=Path, default=default_schema_path())
|
|
22
|
+
validate.add_argument("--profile", default="general", help="Built-in profile name or YAML file path")
|
|
23
|
+
generate = commands.add_parser("generate-schema", help="Generate JSON Schema from LinkML")
|
|
24
|
+
generate.add_argument("--output", type=Path, required=True)
|
|
25
|
+
generate.add_argument("--schema", type=Path, default=default_schema_path())
|
|
26
|
+
commands.add_parser("profiles", help="List built-in profiles and their use contracts")
|
|
27
|
+
return result
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _unique_object(pairs):
|
|
31
|
+
record = {}
|
|
32
|
+
for key, value in pairs:
|
|
33
|
+
if key in record:
|
|
34
|
+
raise ValueError(f"Duplicate JSON key: {key!r}")
|
|
35
|
+
record[key] = value
|
|
36
|
+
return record
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _invalid_constant(value):
|
|
40
|
+
raise ValueError(f"Non-finite JSON constant is not supported: {value}")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
MAX_JSON_DEPTH = 100
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _check_depth(value) -> None:
|
|
47
|
+
"""Reject over-nested input explicitly; the parser's own recursion limit varies by platform."""
|
|
48
|
+
stack = [(value, 1)]
|
|
49
|
+
while stack:
|
|
50
|
+
node, depth = stack.pop()
|
|
51
|
+
if depth > MAX_JSON_DEPTH:
|
|
52
|
+
raise ValueError(f"JSON nesting exceeds {MAX_JSON_DEPTH} levels")
|
|
53
|
+
children = node.values() if isinstance(node, dict) else node if isinstance(node, list) else ()
|
|
54
|
+
stack.extend((child, depth + 1) for child in children if isinstance(child, (dict, list)))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _write_json(path: Path, value: dict) -> None:
|
|
58
|
+
"""Replace the report only after the complete UTF-8 payload is written."""
|
|
59
|
+
payload = json.dumps(value, indent=2, allow_nan=False) + "\n"
|
|
60
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
61
|
+
temp_path = None
|
|
62
|
+
try:
|
|
63
|
+
with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8", newline="\n",
|
|
64
|
+
dir=path.parent, delete=False) as handle:
|
|
65
|
+
temp_path = Path(handle.name)
|
|
66
|
+
handle.write(payload)
|
|
67
|
+
os.replace(temp_path, path)
|
|
68
|
+
finally:
|
|
69
|
+
if temp_path is not None:
|
|
70
|
+
temp_path.unlink(missing_ok=True)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _run(args) -> int:
|
|
74
|
+
if args.command == "generate-schema":
|
|
75
|
+
if args.output.resolve() in {args.schema.resolve(), default_schema_path().resolve()}:
|
|
76
|
+
raise ValueError("Output must not overwrite the schema")
|
|
77
|
+
_write_json(args.output, generate_json_schema(args.schema))
|
|
78
|
+
return 0
|
|
79
|
+
|
|
80
|
+
if args.command == "profiles":
|
|
81
|
+
print(json.dumps(list_profiles(), indent=2))
|
|
82
|
+
return 0
|
|
83
|
+
|
|
84
|
+
selected_profile = profile_path(args.profile)
|
|
85
|
+
protected = [args.input, args.schema, selected_profile, default_schema_path()]
|
|
86
|
+
if args.output and args.output.resolve() in {p.resolve() for p in protected}:
|
|
87
|
+
raise ValueError("Output must not overwrite an input, schema, or profile")
|
|
88
|
+
record = json.loads(args.input.read_text(encoding="utf-8"),
|
|
89
|
+
object_pairs_hook=_unique_object, parse_constant=_invalid_constant)
|
|
90
|
+
_check_depth(record)
|
|
91
|
+
report = validate_record(record, schema_path=args.schema, profile=args.profile)
|
|
92
|
+
rendered = json.dumps(report, indent=2) + "\n"
|
|
93
|
+
if args.output:
|
|
94
|
+
_write_json(args.output, report)
|
|
95
|
+
else:
|
|
96
|
+
print(rendered, end="")
|
|
97
|
+
if report["overall_status"] == "rejected":
|
|
98
|
+
return 1
|
|
99
|
+
if report["overall_status"] == "review_required":
|
|
100
|
+
return 2
|
|
101
|
+
return 0
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def main(argv: list[str] | None = None) -> int:
|
|
105
|
+
args = parser().parse_args(argv)
|
|
106
|
+
try:
|
|
107
|
+
return _run(args)
|
|
108
|
+
except (OSError, UnicodeError, ValueError, RecursionError, yaml.YAMLError) as exc:
|
|
109
|
+
print(json.dumps({"error": "input_or_execution_error", "message": str(exc)}), file=sys.stderr)
|
|
110
|
+
return 3
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
if __name__ == "__main__":
|
|
114
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Strict configuration parsing shared by profile boundaries."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import yaml
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class UniqueKeyLoader(yaml.SafeLoader):
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _mapping(loader, node, deep=False):
|
|
12
|
+
result = {}
|
|
13
|
+
for key_node, value_node in node.value:
|
|
14
|
+
key = loader.construct_object(key_node, deep=deep)
|
|
15
|
+
if not isinstance(key, str):
|
|
16
|
+
raise ValueError("Configuration keys must be strings")
|
|
17
|
+
if key in result:
|
|
18
|
+
raise ValueError(f"Duplicate YAML key: {key!r}")
|
|
19
|
+
result[key] = loader.construct_object(value_node, deep=deep)
|
|
20
|
+
return result
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
UniqueKeyLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, _mapping)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def load_mapping(data: bytes, label: str) -> dict:
|
|
27
|
+
try:
|
|
28
|
+
value = yaml.load(data, Loader=UniqueKeyLoader)
|
|
29
|
+
except yaml.YAMLError as exc:
|
|
30
|
+
raise ValueError(f"Invalid {label} YAML: {exc}") from exc
|
|
31
|
+
if not isinstance(value, dict):
|
|
32
|
+
raise ValueError(f"{label} must be a mapping")
|
|
33
|
+
return value
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def nonblank(value) -> bool:
|
|
37
|
+
return isinstance(value, str) and bool(value.strip())
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import json
|
|
5
|
+
from dataclasses import asdict, dataclass
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from jsonschema import Draft202012Validator, FormatChecker
|
|
11
|
+
from linkml.generators.jsonschemagen import JsonSchemaGenerator
|
|
12
|
+
|
|
13
|
+
from . import __version__
|
|
14
|
+
from .config import load_mapping, nonblank
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True)
|
|
18
|
+
class Finding:
|
|
19
|
+
rule_id: str
|
|
20
|
+
severity: str
|
|
21
|
+
message: str
|
|
22
|
+
field_path: str
|
|
23
|
+
blocking_uses: list[str]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def sha256_bytes(data: bytes) -> str:
|
|
27
|
+
return hashlib.sha256(data).hexdigest()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _resource_path(kind: str, filename: str) -> Path:
|
|
31
|
+
return Path(__file__).resolve().parent / kind / filename
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def default_schema_path() -> Path:
|
|
35
|
+
return _resource_path("schema", "bioevidence_core.yaml")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def generate_json_schema(schema_path: Path | None = None) -> dict[str, Any]:
|
|
39
|
+
schema_path = schema_path or default_schema_path()
|
|
40
|
+
try:
|
|
41
|
+
rendered = JsonSchemaGenerator(str(schema_path), mergeimports=True).serialize()
|
|
42
|
+
schema = json.loads(rendered)
|
|
43
|
+
Draft202012Validator.check_schema(schema)
|
|
44
|
+
return schema
|
|
45
|
+
except Exception as exc:
|
|
46
|
+
raise ValueError(f"Unable to compile LinkML schema: {exc}") from exc
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def profile_path(profile: str | Path = "general") -> Path:
|
|
50
|
+
"""Resolve a built-in name or an explicit YAML path; never silently fall back."""
|
|
51
|
+
if isinstance(profile, str) and profile in {"general", "literature-claim", "dataset-label"}:
|
|
52
|
+
return _resource_path("profiles", profile + ".yaml")
|
|
53
|
+
path = Path(profile)
|
|
54
|
+
if not path.is_file():
|
|
55
|
+
raise ValueError(f"Unknown profile or missing profile file: {profile}")
|
|
56
|
+
return path
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _string_list(value: Any) -> bool:
|
|
60
|
+
return (isinstance(value, list) and all(nonblank(x) for x in value)
|
|
61
|
+
and len(set(value)) == len(value))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def load_profile(data: bytes) -> dict[str, Any]:
|
|
65
|
+
profile = load_mapping(data, "Profile")
|
|
66
|
+
if set(profile) != {"id", "version", "description", "predicates", "subject_types", "object_types", "uses"}:
|
|
67
|
+
raise ValueError("Profile has missing or unknown fields")
|
|
68
|
+
if any(not nonblank(profile[k]) for k in ("id", "version", "description")):
|
|
69
|
+
raise ValueError("Profile id, version and description must be nonblank strings")
|
|
70
|
+
for key in ("predicates", "subject_types", "object_types"):
|
|
71
|
+
if not _string_list(profile[key]):
|
|
72
|
+
raise ValueError(f"Profile {key} must be a list of distinct nonblank strings")
|
|
73
|
+
if not isinstance(profile["uses"], dict) or not profile["uses"]:
|
|
74
|
+
raise ValueError("Profile uses must be a nonempty mapping")
|
|
75
|
+
flags = {"require_human_acceptance", "allow_llm_only", "allow_string_match_only"}
|
|
76
|
+
for name, use in profile["uses"].items():
|
|
77
|
+
if not nonblank(name) or not isinstance(use, dict) or set(use) != flags | {"required_evidence_types"}:
|
|
78
|
+
raise ValueError(f"Invalid or incomplete use configuration: {name!r}")
|
|
79
|
+
if any(type(use[key]) is not bool for key in flags) or not _string_list(use["required_evidence_types"]):
|
|
80
|
+
raise ValueError(f"Use {name!r} requires boolean flags and distinct evidence types")
|
|
81
|
+
return profile
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def list_profiles() -> list[dict[str, Any]]:
|
|
85
|
+
return [load_profile(profile_path(name).read_bytes())
|
|
86
|
+
for name in ("general", "literature-claim", "dataset-label")]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _schema_findings(record: Any, rendered: dict, uses: list[str]) -> list[Finding]:
|
|
90
|
+
validator = Draft202012Validator(rendered, format_checker=FormatChecker())
|
|
91
|
+
findings = []
|
|
92
|
+
for error in sorted(validator.iter_errors(record), key=lambda e: tuple(str(p) for p in e.absolute_path)):
|
|
93
|
+
path = "$" + "".join(f"[{p}]" if isinstance(p, int) else f".{p}" for p in error.absolute_path)
|
|
94
|
+
findings.append(Finding("SCHEMA", "error", error.message, path, uses))
|
|
95
|
+
return findings
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _integrity_findings(record: dict, profile: dict) -> list[Finding]:
|
|
99
|
+
findings = []
|
|
100
|
+
uses = record["requested_uses"]
|
|
101
|
+
statement = record["statement"]
|
|
102
|
+
|
|
103
|
+
def error(message, path):
|
|
104
|
+
findings.append(Finding("RECORD_INTEGRITY", "error", message, path, uses))
|
|
105
|
+
|
|
106
|
+
if record["profile_id"] != profile["id"]:
|
|
107
|
+
error("Record profile_id does not match the explicitly selected profile.", "$.profile_id")
|
|
108
|
+
if not _string_list(uses) or not uses or set(uses) - profile["uses"].keys():
|
|
109
|
+
error("requested_uses must contain distinct uses supported by the selected profile.", "$.requested_uses")
|
|
110
|
+
collections = [("$.source_artifacts", record["source_artifacts"]),
|
|
111
|
+
("$.evidence_items", record["evidence_items"]),
|
|
112
|
+
("$.statement.evidence_lines", statement["evidence_lines"]),
|
|
113
|
+
("$.adjudications", record.get("adjudications") or [])]
|
|
114
|
+
for path, rows in collections:
|
|
115
|
+
identities = [row["id"] for row in rows]
|
|
116
|
+
if len(identities) != len(set(identities)):
|
|
117
|
+
error("Duplicate identifiers make references ambiguous.", path)
|
|
118
|
+
artifacts = {row["id"] for row in record["source_artifacts"]}
|
|
119
|
+
items = {row["id"] for row in record["evidence_items"]}
|
|
120
|
+
for index, item in enumerate(record["evidence_items"]):
|
|
121
|
+
if item["source_artifact_id"] not in artifacts:
|
|
122
|
+
error("Evidence references an absent source artifact.", f"$.evidence_items[{index}].source_artifact_id")
|
|
123
|
+
if not _string_list(item["scope"]):
|
|
124
|
+
error("Scope must contain distinct tokens.", f"$.evidence_items[{index}].scope")
|
|
125
|
+
if not _string_list(statement["scope"]):
|
|
126
|
+
error("Scope must contain distinct tokens.", "$.statement.scope")
|
|
127
|
+
for index, line in enumerate(statement["evidence_lines"]):
|
|
128
|
+
refs = line["evidence_item_ids"]
|
|
129
|
+
if not _string_list(refs) or set(refs) - items:
|
|
130
|
+
error("Evidence line has duplicate or unresolved item references.", f"$.statement.evidence_lines[{index}].evidence_item_ids")
|
|
131
|
+
for index, decision in enumerate(record.get("adjudications") or []):
|
|
132
|
+
if decision["statement_id"] != statement["id"]:
|
|
133
|
+
error("Adjudication targets a different statement.", f"$.adjudications[{index}].statement_id")
|
|
134
|
+
targets = decision["applies_to_uses"]
|
|
135
|
+
if not _string_list(targets) or set(targets) - profile["uses"].keys():
|
|
136
|
+
error("Adjudication uses must be distinct and supported by this profile.", f"$.adjudications[{index}].applies_to_uses")
|
|
137
|
+
return findings
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def evaluate_profile(record: dict, profile: dict) -> list[Finding]:
|
|
141
|
+
"""Fixed evidence checks plus declarative use contracts; no domain dispatch."""
|
|
142
|
+
findings = []
|
|
143
|
+
requested = record["requested_uses"]
|
|
144
|
+
statement = record["statement"]
|
|
145
|
+
items = {x["id"]: x for x in record["evidence_items"]}
|
|
146
|
+
|
|
147
|
+
def add(code, severity, message, path, uses=None):
|
|
148
|
+
findings.append(Finding(code, severity, message, path, requested if uses is None else uses))
|
|
149
|
+
|
|
150
|
+
if statement["statement_status"] in {"rejected", "superseded"}:
|
|
151
|
+
add("BEV001", "error", "A rejected or superseded statement is ineligible.", "$.statement.statement_status")
|
|
152
|
+
for index, source in enumerate(record["source_artifacts"]):
|
|
153
|
+
if source.get("observed_sha256") and source["observed_sha256"] != source["sha256"]:
|
|
154
|
+
add("BEV002", "error", "Observed source hash differs from the frozen hash.", f"$.source_artifacts[{index}].observed_sha256")
|
|
155
|
+
for key, value, path in [("predicates", statement["predicate"], "$.statement.predicate"),
|
|
156
|
+
("subject_types", statement["subject"]["entity_type"], "$.statement.subject.entity_type"),
|
|
157
|
+
("object_types", statement["object"]["entity_type"], "$.statement.object.entity_type")]:
|
|
158
|
+
if profile[key] and value not in profile[key]:
|
|
159
|
+
add("BEV003", "error", f"Value is outside the profile's allowed {key}.", path)
|
|
160
|
+
supporting = {}
|
|
161
|
+
for index, line in enumerate(statement["evidence_lines"]):
|
|
162
|
+
if line["direction"] == "contradicts":
|
|
163
|
+
add("BEV004", "review", "Contradicting evidence remains unresolved.", f"$.statement.evidence_lines[{index}]")
|
|
164
|
+
if line["direction"] == "supports":
|
|
165
|
+
for item_id in line["evidence_item_ids"]:
|
|
166
|
+
item = items[item_id]
|
|
167
|
+
if set(item["scope"]) != set(statement["scope"]):
|
|
168
|
+
add("BEV005", "error", "Supporting evidence scope must match the statement's explicit scope tokens.", f"$.statement.evidence_lines[{index}]")
|
|
169
|
+
else:
|
|
170
|
+
supporting[item_id] = item
|
|
171
|
+
if not supporting:
|
|
172
|
+
add("BEV006", "review", "No resolved, scope-matched supporting evidence.", "$.statement.evidence_lines")
|
|
173
|
+
types = {item["evidence_type"] for item in supporting.values()}
|
|
174
|
+
decisions = record.get("adjudications") or []
|
|
175
|
+
for use in requested:
|
|
176
|
+
contract = profile["uses"][use]
|
|
177
|
+
missing = set(contract["required_evidence_types"]) - types
|
|
178
|
+
if missing:
|
|
179
|
+
add("BEV007", "error", "Missing supporting evidence types: " + ", ".join(sorted(missing)), "$.evidence_items", [use])
|
|
180
|
+
# Each required evidence type must independently satisfy the quality gate.
|
|
181
|
+
# An unrelated manually curated note cannot strengthen a required LLM result.
|
|
182
|
+
groups = [(kind, [item for item in supporting.values() if item["evidence_type"] == kind])
|
|
183
|
+
for kind in contract["required_evidence_types"]]
|
|
184
|
+
if not groups:
|
|
185
|
+
groups = [(None, list(supporting.values()))]
|
|
186
|
+
for kind, evidence in groups:
|
|
187
|
+
methods = {item["extraction_method"] for item in evidence}
|
|
188
|
+
context = f"Required evidence type {kind!r}" if kind is not None else "Supporting evidence"
|
|
189
|
+
if methods == {"llm_extraction"} and not contract["allow_llm_only"]:
|
|
190
|
+
add("BEV008", "review", context + " comes only from LLM extraction.", "$.evidence_items", [use])
|
|
191
|
+
if methods == {"normalized_string_match"} and not contract["allow_string_match_only"]:
|
|
192
|
+
add("BEV009", "review", context + " comes only from normalized string matching.", "$.evidence_items", [use])
|
|
193
|
+
if len(methods) > 1 and methods <= {"llm_extraction", "normalized_string_match"}:
|
|
194
|
+
if not (contract["allow_llm_only"] and contract["allow_string_match_only"]):
|
|
195
|
+
add("BEV013", "review", context + " mixes only LLM extraction and string matching.", "$.evidence_items", [use])
|
|
196
|
+
human = {d["decision"] for d in decisions if d["reviewer"]["agent_type"] == "human" and use in d["applies_to_uses"]}
|
|
197
|
+
if contract["require_human_acceptance"] and "accept" not in human:
|
|
198
|
+
add("BEV010", "error", "This use requires explicit human acceptance.", "$.adjudications", [use])
|
|
199
|
+
if "reject" in human:
|
|
200
|
+
add("BEV011", "error", "Human rejection remains present for this use.", "$.adjudications", [use])
|
|
201
|
+
if "defer" in human:
|
|
202
|
+
add("BEV012", "review", "A human decision is deferred for this use.", "$.adjudications", [use])
|
|
203
|
+
return findings
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def decide_uses(requested_uses: list[str], findings: list[Finding]) -> list[dict[str, Any]]:
|
|
207
|
+
decisions = []
|
|
208
|
+
for use in requested_uses:
|
|
209
|
+
relevant = [f for f in findings if f.rule_id in {"SCHEMA", "RECORD_INTEGRITY"} or use in f.blocking_uses]
|
|
210
|
+
status = ("rejected" if any(f.severity == "error" for f in relevant) else
|
|
211
|
+
"review_required" if any(f.severity == "review" for f in relevant) else "admitted")
|
|
212
|
+
decisions.append({"use": use, "admission_status": status, "reason_codes": sorted({f.rule_id for f in relevant})})
|
|
213
|
+
return decisions
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
class RecordValidator:
|
|
217
|
+
"""Snapshot a profile and compile schemas once for a consistent batch.
|
|
218
|
+
|
|
219
|
+
A trusted custom LinkML schema may add constraints; baseline checks always run.
|
|
220
|
+
Source bytes and reviewer identities are supplied assertions, not authenticated here.
|
|
221
|
+
"""
|
|
222
|
+
def __init__(self, *, profile: str | Path = "general", schema_path: Path | None = None):
|
|
223
|
+
profile_bytes = profile_path(profile).read_bytes()
|
|
224
|
+
self._profile = load_profile(profile_bytes)
|
|
225
|
+
self.profile_sha256 = sha256_bytes(profile_bytes)
|
|
226
|
+
baseline = default_schema_path().resolve()
|
|
227
|
+
selected = Path(schema_path or baseline).resolve()
|
|
228
|
+
paths = [baseline] if selected == baseline else [baseline, selected]
|
|
229
|
+
self._schemas = [generate_json_schema(path) for path in paths]
|
|
230
|
+
versions = [str(load_mapping(path.read_bytes(), "Schema").get("version", "unknown")) for path in paths]
|
|
231
|
+
self.schema_version = versions[-1]
|
|
232
|
+
self.schema_sources = [{"role": "baseline" if i == 0 else "extension", "version": versions[i],
|
|
233
|
+
"sha256": sha256_bytes(json.dumps(schema, sort_keys=True, separators=(",", ":")).encode())}
|
|
234
|
+
for i, schema in enumerate(self._schemas)]
|
|
235
|
+
self.schema_sha256 = (self.schema_sources[0]["sha256"] if len(paths) == 1 else
|
|
236
|
+
sha256_bytes(json.dumps(self._schemas, sort_keys=True, separators=(",", ":")).encode()))
|
|
237
|
+
|
|
238
|
+
def validate(self, record: Any) -> dict[str, Any]:
|
|
239
|
+
canonical = json.dumps(record, sort_keys=True, separators=(",", ":"), allow_nan=False).encode()
|
|
240
|
+
requested = record.get("requested_uses") if isinstance(record, dict) else None
|
|
241
|
+
uses = list(dict.fromkeys(use for use in requested if isinstance(use, str))) if isinstance(requested, list) else []
|
|
242
|
+
findings = []
|
|
243
|
+
for rendered in self._schemas:
|
|
244
|
+
findings.extend(_schema_findings(record, rendered, uses))
|
|
245
|
+
if not findings:
|
|
246
|
+
findings.extend(_integrity_findings(record, self._profile))
|
|
247
|
+
if not findings:
|
|
248
|
+
findings.extend(evaluate_profile(record, self._profile))
|
|
249
|
+
decisions = decide_uses(uses, findings)
|
|
250
|
+
overall = ("rejected" if not decisions or any(f.severity == "error" for f in findings) else
|
|
251
|
+
"review_required" if any(x["admission_status"] == "review_required" for x in decisions) else "admitted")
|
|
252
|
+
return {
|
|
253
|
+
"validator": "bioai-evidence-validator", "validator_version": __version__,
|
|
254
|
+
"profile_id": self._profile["id"], "profile_version": self._profile["version"],
|
|
255
|
+
"profile_sha256": self.profile_sha256,
|
|
256
|
+
"schema_version": self.schema_version, "schema_sha256": self.schema_sha256,
|
|
257
|
+
"schema_sources": [dict(source) for source in self.schema_sources],
|
|
258
|
+
"input_sha256": sha256_bytes(canonical), "validated_at": datetime.now(timezone.utc).isoformat(),
|
|
259
|
+
"schema_valid": not any(f.rule_id == "SCHEMA" for f in findings),
|
|
260
|
+
"overall_status": overall, "findings": [asdict(f) for f in findings], "use_decisions": decisions,
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def validate_record(record: Any, *, profile: str | Path = "general", schema_path: Path | None = None) -> dict[str, Any]:
|
|
265
|
+
return RecordValidator(profile=profile, schema_path=schema_path).validate(record)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
id: dataset-label
|
|
2
|
+
version: 0.4.1
|
|
3
|
+
description: Dataset label evidence and sample-link review; supplied metadata does
|
|
4
|
+
not prove biological membership.
|
|
5
|
+
predicates:
|
|
6
|
+
- has_label
|
|
7
|
+
subject_types:
|
|
8
|
+
- sample
|
|
9
|
+
object_types:
|
|
10
|
+
- cell_type
|
|
11
|
+
- phenotype
|
|
12
|
+
- class_label
|
|
13
|
+
uses:
|
|
14
|
+
reference_annotation:
|
|
15
|
+
required_evidence_types:
|
|
16
|
+
- curated_label
|
|
17
|
+
- sample_link
|
|
18
|
+
require_human_acceptance: false
|
|
19
|
+
allow_llm_only: false
|
|
20
|
+
allow_string_match_only: false
|
|
21
|
+
training_data:
|
|
22
|
+
required_evidence_types:
|
|
23
|
+
- curated_label
|
|
24
|
+
- sample_link
|
|
25
|
+
require_human_acceptance: true
|
|
26
|
+
allow_llm_only: false
|
|
27
|
+
allow_string_match_only: false
|
|
28
|
+
external_validation:
|
|
29
|
+
required_evidence_types:
|
|
30
|
+
- curated_label
|
|
31
|
+
- sample_link
|
|
32
|
+
- independent_cohort_review
|
|
33
|
+
require_human_acceptance: true
|
|
34
|
+
allow_llm_only: false
|
|
35
|
+
allow_string_match_only: false
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
id: general
|
|
2
|
+
version: 0.4.1
|
|
3
|
+
description: General provenance, evidence scope and use admission; no biological domain
|
|
4
|
+
assumptions.
|
|
5
|
+
predicates: []
|
|
6
|
+
subject_types: []
|
|
7
|
+
object_types: []
|
|
8
|
+
uses:
|
|
9
|
+
knowledge_base:
|
|
10
|
+
required_evidence_types: []
|
|
11
|
+
require_human_acceptance: false
|
|
12
|
+
allow_llm_only: false
|
|
13
|
+
allow_string_match_only: false
|
|
14
|
+
research_summary:
|
|
15
|
+
required_evidence_types: []
|
|
16
|
+
require_human_acceptance: false
|
|
17
|
+
allow_llm_only: false
|
|
18
|
+
allow_string_match_only: false
|
|
19
|
+
training_data:
|
|
20
|
+
required_evidence_types: []
|
|
21
|
+
require_human_acceptance: true
|
|
22
|
+
allow_llm_only: false
|
|
23
|
+
allow_string_match_only: false
|
|
24
|
+
external_validation:
|
|
25
|
+
required_evidence_types: []
|
|
26
|
+
require_human_acceptance: true
|
|
27
|
+
allow_llm_only: false
|
|
28
|
+
allow_string_match_only: false
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
id: literature-claim
|
|
2
|
+
version: 0.4.1
|
|
3
|
+
description: Synthetic gene/phenotype literature-claim curation example, not a clinical
|
|
4
|
+
interpretation guideline.
|
|
5
|
+
predicates:
|
|
6
|
+
- associated_with
|
|
7
|
+
- contributes_to
|
|
8
|
+
subject_types:
|
|
9
|
+
- gene
|
|
10
|
+
- variant
|
|
11
|
+
object_types:
|
|
12
|
+
- phenotype
|
|
13
|
+
- disease
|
|
14
|
+
uses:
|
|
15
|
+
research_summary:
|
|
16
|
+
required_evidence_types:
|
|
17
|
+
- publication_result
|
|
18
|
+
require_human_acceptance: false
|
|
19
|
+
allow_llm_only: false
|
|
20
|
+
allow_string_match_only: false
|
|
21
|
+
knowledge_base:
|
|
22
|
+
required_evidence_types:
|
|
23
|
+
- publication_result
|
|
24
|
+
require_human_acceptance: true
|
|
25
|
+
allow_llm_only: false
|
|
26
|
+
allow_string_match_only: false
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
id: https://w3id.org/bioevidence/core
|
|
2
|
+
name: bioevidence_core
|
|
3
|
+
title: BioEvidence operational core
|
|
4
|
+
description: Domain-neutral evidence records for biological assertions, source provenance,
|
|
5
|
+
scoped adjudication, and use-specific admission.
|
|
6
|
+
license: Apache-2.0
|
|
7
|
+
version: 0.4.0
|
|
8
|
+
prefixes:
|
|
9
|
+
bioev: https://w3id.org/bioevidence/
|
|
10
|
+
linkml: https://w3id.org/linkml/
|
|
11
|
+
prov: http://www.w3.org/ns/prov#
|
|
12
|
+
sepio: http://purl.obolibrary.org/obo/SEPIO_
|
|
13
|
+
default_prefix: bioev
|
|
14
|
+
default_range: string
|
|
15
|
+
imports:
|
|
16
|
+
- linkml:types
|
|
17
|
+
enums:
|
|
18
|
+
AgentType:
|
|
19
|
+
permissible_values:
|
|
20
|
+
human: null
|
|
21
|
+
software: null
|
|
22
|
+
organization: null
|
|
23
|
+
SourceType:
|
|
24
|
+
permissible_values:
|
|
25
|
+
ontology_snapshot: null
|
|
26
|
+
registry_snapshot: null
|
|
27
|
+
dataset_snapshot: null
|
|
28
|
+
publication: null
|
|
29
|
+
web_page: null
|
|
30
|
+
local_file: null
|
|
31
|
+
EvidenceDirection:
|
|
32
|
+
permissible_values:
|
|
33
|
+
supports: null
|
|
34
|
+
contradicts: null
|
|
35
|
+
neutral: null
|
|
36
|
+
ExtractionMethod:
|
|
37
|
+
permissible_values:
|
|
38
|
+
deterministic_parser: null
|
|
39
|
+
manual_curation: null
|
|
40
|
+
normalized_string_match: null
|
|
41
|
+
llm_extraction: null
|
|
42
|
+
StatementStatus:
|
|
43
|
+
permissible_values:
|
|
44
|
+
proposed: null
|
|
45
|
+
accepted: null
|
|
46
|
+
rejected: null
|
|
47
|
+
superseded: null
|
|
48
|
+
AdjudicationDecision:
|
|
49
|
+
permissible_values:
|
|
50
|
+
accept: null
|
|
51
|
+
reject: null
|
|
52
|
+
defer: null
|
|
53
|
+
FindingSeverity:
|
|
54
|
+
permissible_values:
|
|
55
|
+
error: null
|
|
56
|
+
review: null
|
|
57
|
+
warning: null
|
|
58
|
+
AdmissionStatus:
|
|
59
|
+
permissible_values:
|
|
60
|
+
admitted: null
|
|
61
|
+
review_required: null
|
|
62
|
+
rejected: null
|
|
63
|
+
not_evaluated: null
|
|
64
|
+
slots:
|
|
65
|
+
id:
|
|
66
|
+
pattern: \S
|
|
67
|
+
identifier: true
|
|
68
|
+
range: uriorcurie
|
|
69
|
+
required: true
|
|
70
|
+
name:
|
|
71
|
+
range: string
|
|
72
|
+
agent_type:
|
|
73
|
+
range: AgentType
|
|
74
|
+
required: true
|
|
75
|
+
title:
|
|
76
|
+
pattern: \S
|
|
77
|
+
range: string
|
|
78
|
+
required: true
|
|
79
|
+
source_type:
|
|
80
|
+
range: SourceType
|
|
81
|
+
required: true
|
|
82
|
+
uri:
|
|
83
|
+
range: uri
|
|
84
|
+
version:
|
|
85
|
+
pattern: \S
|
|
86
|
+
range: string
|
|
87
|
+
required: true
|
|
88
|
+
retrieved_at:
|
|
89
|
+
range: datetime
|
|
90
|
+
required: true
|
|
91
|
+
sha256:
|
|
92
|
+
range: string
|
|
93
|
+
pattern: ^[0-9a-f]{64}$
|
|
94
|
+
required: true
|
|
95
|
+
observed_sha256:
|
|
96
|
+
range: string
|
|
97
|
+
pattern: ^[0-9a-f]{64}$
|
|
98
|
+
source_artifact_id:
|
|
99
|
+
pattern: \S
|
|
100
|
+
range: uriorcurie
|
|
101
|
+
required: true
|
|
102
|
+
locator:
|
|
103
|
+
pattern: \S
|
|
104
|
+
range: string
|
|
105
|
+
required: true
|
|
106
|
+
extracted_text:
|
|
107
|
+
range: string
|
|
108
|
+
evidence_type:
|
|
109
|
+
pattern: \S
|
|
110
|
+
range: string
|
|
111
|
+
required: true
|
|
112
|
+
extraction_method:
|
|
113
|
+
range: ExtractionMethod
|
|
114
|
+
required: true
|
|
115
|
+
created_by:
|
|
116
|
+
range: Agent
|
|
117
|
+
inlined: true
|
|
118
|
+
evidence_item_ids:
|
|
119
|
+
pattern: \S
|
|
120
|
+
required: true
|
|
121
|
+
range: uriorcurie
|
|
122
|
+
multivalued: true
|
|
123
|
+
minimum_cardinality: 1
|
|
124
|
+
direction:
|
|
125
|
+
range: EvidenceDirection
|
|
126
|
+
required: true
|
|
127
|
+
rationale:
|
|
128
|
+
pattern: \S
|
|
129
|
+
range: string
|
|
130
|
+
evidence_lines:
|
|
131
|
+
required: true
|
|
132
|
+
range: EvidenceLine
|
|
133
|
+
multivalued: true
|
|
134
|
+
inlined: true
|
|
135
|
+
inlined_as_list: true
|
|
136
|
+
minimum_cardinality: 1
|
|
137
|
+
statement_status:
|
|
138
|
+
range: StatementStatus
|
|
139
|
+
required: true
|
|
140
|
+
decision:
|
|
141
|
+
range: AdjudicationDecision
|
|
142
|
+
required: true
|
|
143
|
+
reviewer:
|
|
144
|
+
range: Agent
|
|
145
|
+
inlined: true
|
|
146
|
+
required: true
|
|
147
|
+
decided_at:
|
|
148
|
+
range: datetime
|
|
149
|
+
required: true
|
|
150
|
+
rule_id:
|
|
151
|
+
range: string
|
|
152
|
+
required: true
|
|
153
|
+
severity:
|
|
154
|
+
range: FindingSeverity
|
|
155
|
+
required: true
|
|
156
|
+
message:
|
|
157
|
+
range: string
|
|
158
|
+
required: true
|
|
159
|
+
field_path:
|
|
160
|
+
range: string
|
|
161
|
+
blocking_uses:
|
|
162
|
+
range: string
|
|
163
|
+
multivalued: true
|
|
164
|
+
use:
|
|
165
|
+
range: string
|
|
166
|
+
required: true
|
|
167
|
+
admission_status:
|
|
168
|
+
range: AdmissionStatus
|
|
169
|
+
required: true
|
|
170
|
+
reason_codes:
|
|
171
|
+
range: string
|
|
172
|
+
multivalued: true
|
|
173
|
+
record_id:
|
|
174
|
+
identifier: true
|
|
175
|
+
range: string
|
|
176
|
+
pattern: \S
|
|
177
|
+
required: true
|
|
178
|
+
profile_id:
|
|
179
|
+
range: string
|
|
180
|
+
pattern: \S
|
|
181
|
+
required: true
|
|
182
|
+
statement:
|
|
183
|
+
range: Statement
|
|
184
|
+
inlined: true
|
|
185
|
+
required: true
|
|
186
|
+
source_artifacts:
|
|
187
|
+
range: SourceArtifact
|
|
188
|
+
inlined: true
|
|
189
|
+
required: true
|
|
190
|
+
multivalued: true
|
|
191
|
+
inlined_as_list: true
|
|
192
|
+
minimum_cardinality: 1
|
|
193
|
+
evidence_items:
|
|
194
|
+
range: EvidenceItem
|
|
195
|
+
inlined: true
|
|
196
|
+
required: true
|
|
197
|
+
multivalued: true
|
|
198
|
+
inlined_as_list: true
|
|
199
|
+
minimum_cardinality: 1
|
|
200
|
+
adjudications:
|
|
201
|
+
range: Adjudication
|
|
202
|
+
inlined: true
|
|
203
|
+
multivalued: true
|
|
204
|
+
inlined_as_list: true
|
|
205
|
+
minimum_cardinality: 0
|
|
206
|
+
requested_uses:
|
|
207
|
+
range: string
|
|
208
|
+
pattern: \S
|
|
209
|
+
required: true
|
|
210
|
+
multivalued: true
|
|
211
|
+
minimum_cardinality: 1
|
|
212
|
+
subject:
|
|
213
|
+
range: Entity
|
|
214
|
+
inlined: true
|
|
215
|
+
required: true
|
|
216
|
+
object:
|
|
217
|
+
range: Entity
|
|
218
|
+
inlined: true
|
|
219
|
+
required: true
|
|
220
|
+
label:
|
|
221
|
+
range: string
|
|
222
|
+
pattern: \S
|
|
223
|
+
required: true
|
|
224
|
+
entity_type:
|
|
225
|
+
range: string
|
|
226
|
+
pattern: \S
|
|
227
|
+
required: true
|
|
228
|
+
predicate:
|
|
229
|
+
range: string
|
|
230
|
+
pattern: \S
|
|
231
|
+
required: true
|
|
232
|
+
scope:
|
|
233
|
+
range: string
|
|
234
|
+
pattern: \S
|
|
235
|
+
required: true
|
|
236
|
+
multivalued: true
|
|
237
|
+
minimum_cardinality: 1
|
|
238
|
+
statement_id:
|
|
239
|
+
range: string
|
|
240
|
+
pattern: \S
|
|
241
|
+
required: true
|
|
242
|
+
applies_to_uses:
|
|
243
|
+
range: string
|
|
244
|
+
pattern: \S
|
|
245
|
+
required: true
|
|
246
|
+
multivalued: true
|
|
247
|
+
minimum_cardinality: 1
|
|
248
|
+
classes:
|
|
249
|
+
Agent:
|
|
250
|
+
class_uri: prov:Agent
|
|
251
|
+
slots:
|
|
252
|
+
- id
|
|
253
|
+
- name
|
|
254
|
+
- agent_type
|
|
255
|
+
SourceArtifact:
|
|
256
|
+
description: Immutable description of the exact source bytes used by a decision.
|
|
257
|
+
class_uri: prov:Entity
|
|
258
|
+
slots:
|
|
259
|
+
- id
|
|
260
|
+
- title
|
|
261
|
+
- source_type
|
|
262
|
+
- uri
|
|
263
|
+
- version
|
|
264
|
+
- retrieved_at
|
|
265
|
+
- sha256
|
|
266
|
+
- observed_sha256
|
|
267
|
+
EvidenceItem:
|
|
268
|
+
description: A located, typed unit of evidence extracted from one source artifact.
|
|
269
|
+
slots:
|
|
270
|
+
- id
|
|
271
|
+
- source_artifact_id
|
|
272
|
+
- locator
|
|
273
|
+
- extracted_text
|
|
274
|
+
- evidence_type
|
|
275
|
+
- extraction_method
|
|
276
|
+
- created_by
|
|
277
|
+
- scope
|
|
278
|
+
EvidenceLine:
|
|
279
|
+
description: An explicit supporting, contradicting, or neutral evidence relationship.
|
|
280
|
+
slots:
|
|
281
|
+
- id
|
|
282
|
+
- direction
|
|
283
|
+
- evidence_item_ids
|
|
284
|
+
- rationale
|
|
285
|
+
Statement:
|
|
286
|
+
slots:
|
|
287
|
+
- id
|
|
288
|
+
- subject
|
|
289
|
+
- predicate
|
|
290
|
+
- object
|
|
291
|
+
- scope
|
|
292
|
+
- evidence_lines
|
|
293
|
+
- statement_status
|
|
294
|
+
- created_by
|
|
295
|
+
Adjudication:
|
|
296
|
+
description: A human decision that never overwrites the underlying evidence or
|
|
297
|
+
findings.
|
|
298
|
+
slots:
|
|
299
|
+
- id
|
|
300
|
+
- statement_id
|
|
301
|
+
- applies_to_uses
|
|
302
|
+
- decision
|
|
303
|
+
- reviewer
|
|
304
|
+
- rationale
|
|
305
|
+
- decided_at
|
|
306
|
+
slot_usage:
|
|
307
|
+
rationale:
|
|
308
|
+
required: true
|
|
309
|
+
Finding:
|
|
310
|
+
slots:
|
|
311
|
+
- rule_id
|
|
312
|
+
- severity
|
|
313
|
+
- message
|
|
314
|
+
- field_path
|
|
315
|
+
- blocking_uses
|
|
316
|
+
UseDecision:
|
|
317
|
+
slots:
|
|
318
|
+
- use
|
|
319
|
+
- admission_status
|
|
320
|
+
- reason_codes
|
|
321
|
+
Entity:
|
|
322
|
+
description: A domain entity with caller-supplied stable identity and type.
|
|
323
|
+
slots:
|
|
324
|
+
- id
|
|
325
|
+
- label
|
|
326
|
+
- entity_type
|
|
327
|
+
BioEvidenceRecord:
|
|
328
|
+
tree_root: true
|
|
329
|
+
slots:
|
|
330
|
+
- record_id
|
|
331
|
+
- profile_id
|
|
332
|
+
- statement
|
|
333
|
+
- source_artifacts
|
|
334
|
+
- evidence_items
|
|
335
|
+
- adjudications
|
|
336
|
+
- requested_uses
|