commissura 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.
- commissura-0.1.0/.gitattributes +43 -0
- commissura-0.1.0/.github/workflows/ci.yml +241 -0
- commissura-0.1.0/.github/workflows/publish.yml +173 -0
- commissura-0.1.0/.github/workflows/upstream.yml +66 -0
- commissura-0.1.0/.gitignore +97 -0
- commissura-0.1.0/.python-version +1 -0
- commissura-0.1.0/CHANGELOG.md +51 -0
- commissura-0.1.0/LICENSE +202 -0
- commissura-0.1.0/NOTICE +78 -0
- commissura-0.1.0/PKG-INFO +2079 -0
- commissura-0.1.0/README.md +2040 -0
- commissura-0.1.0/pyproject.toml +158 -0
- commissura-0.1.0/src/commissura/__init__.py +16 -0
- commissura-0.1.0/src/commissura/__main__.py +6 -0
- commissura-0.1.0/src/commissura/annotate.py +235 -0
- commissura-0.1.0/src/commissura/build/__init__.py +1 -0
- commissura-0.1.0/src/commissura/build/integrity.py +263 -0
- commissura-0.1.0/src/commissura/build/manifest.py +1256 -0
- commissura-0.1.0/src/commissura/build/observe.py +545 -0
- commissura-0.1.0/src/commissura/build/optout.py +416 -0
- commissura-0.1.0/src/commissura/build/publish.py +353 -0
- commissura-0.1.0/src/commissura/build/report.py +491 -0
- commissura-0.1.0/src/commissura/build/risk.py +409 -0
- commissura-0.1.0/src/commissura/build/scrub.py +778 -0
- commissura-0.1.0/src/commissura/build/writer.py +834 -0
- commissura-0.1.0/src/commissura/cli.py +1405 -0
- commissura-0.1.0/src/commissura/deident/__init__.py +1 -0
- commissura-0.1.0/src/commissura/deident/keys.py +324 -0
- commissura-0.1.0/src/commissura/deident/pseudonymise.py +571 -0
- commissura-0.1.0/src/commissura/generate/__init__.py +1 -0
- commissura-0.1.0/src/commissura/generate/cda.py +1440 -0
- commissura-0.1.0/src/commissura/generate/cohort.py +446 -0
- commissura-0.1.0/src/commissura/generate/defects.py +373 -0
- commissura-0.1.0/src/commissura/generate/imaging.py +354 -0
- commissura-0.1.0/src/commissura/generate/labs.py +405 -0
- commissura-0.1.0/src/commissura/generate/reports.py +448 -0
- commissura-0.1.0/src/commissura/generate/vocabulary.py +594 -0
- commissura-0.1.0/src/commissura/generate/writer.py +490 -0
- commissura-0.1.0/src/commissura/healthdcat.py +1042 -0
- commissura-0.1.0/src/commissura/hl7.py +289 -0
- commissura-0.1.0/src/commissura/identifiers.py +358 -0
- commissura-0.1.0/src/commissura/layout.py +413 -0
- commissura-0.1.0/src/commissura/measure.py +464 -0
- commissura-0.1.0/src/commissura/models.py +396 -0
- commissura-0.1.0/src/commissura/py.typed +0 -0
- commissura-0.1.0/src/commissura/read/__init__.py +1 -0
- commissura-0.1.0/src/commissura/read/cda.py +903 -0
- commissura-0.1.0/src/commissura/read/corpus.py +1117 -0
- commissura-0.1.0/src/commissura/read/hl7.py +311 -0
- commissura-0.1.0/src/commissura/read/identity.py +1004 -0
- commissura-0.1.0/src/commissura/validate/__init__.py +24 -0
- commissura-0.1.0/src/commissura/validate/context.py +327 -0
- commissura-0.1.0/src/commissura/validate/findings.py +163 -0
- commissura-0.1.0/src/commissura/validate/rules/__init__.py +26 -0
- commissura-0.1.0/src/commissura/validate/rules/_registry.py +103 -0
- commissura-0.1.0/src/commissura/validate/rules/deident.py +325 -0
- commissura-0.1.0/src/commissura/validate/rules/extension.py +166 -0
- commissura-0.1.0/src/commissura/validate/rules/naming.py +204 -0
- commissura-0.1.0/src/commissura/validate/rules/participants.py +199 -0
- commissura-0.1.0/src/commissura/validate/rules/structure.py +209 -0
- commissura-0.1.0/src/commissura/validate/runner.py +64 -0
- commissura-0.1.0/tests/conftest.py +292 -0
- commissura-0.1.0/tests/test_age_band.py +425 -0
- commissura-0.1.0/tests/test_annotate.py +93 -0
- commissura-0.1.0/tests/test_audit_findings.py +243 -0
- commissura-0.1.0/tests/test_build.py +1332 -0
- commissura-0.1.0/tests/test_cda.py +867 -0
- commissura-0.1.0/tests/test_cda_corpus.py +517 -0
- commissura-0.1.0/tests/test_cda_narrative.py +292 -0
- commissura-0.1.0/tests/test_cda_profiles.py +404 -0
- commissura-0.1.0/tests/test_cda_summary.py +504 -0
- commissura-0.1.0/tests/test_cda_writer.py +187 -0
- commissura-0.1.0/tests/test_claims.py +347 -0
- commissura-0.1.0/tests/test_cli.py +1058 -0
- commissura-0.1.0/tests/test_corpus.py +275 -0
- commissura-0.1.0/tests/test_declared_claims.py +609 -0
- commissura-0.1.0/tests/test_defects.py +153 -0
- commissura-0.1.0/tests/test_documentation_requirements.py +366 -0
- commissura-0.1.0/tests/test_enrolment.py +370 -0
- commissura-0.1.0/tests/test_findings.py +151 -0
- commissura-0.1.0/tests/test_healthdcat.py +867 -0
- commissura-0.1.0/tests/test_hl7.py +132 -0
- commissura-0.1.0/tests/test_identifiers.py +134 -0
- commissura-0.1.0/tests/test_identity.py +988 -0
- commissura-0.1.0/tests/test_identity_defects.py +306 -0
- commissura-0.1.0/tests/test_imaging.py +163 -0
- commissura-0.1.0/tests/test_integrity.py +252 -0
- commissura-0.1.0/tests/test_keys.py +318 -0
- commissura-0.1.0/tests/test_labs.py +214 -0
- commissura-0.1.0/tests/test_layout.py +145 -0
- commissura-0.1.0/tests/test_line_endings.py +98 -0
- commissura-0.1.0/tests/test_manifest_consistency.py +334 -0
- commissura-0.1.0/tests/test_measure.py +446 -0
- commissura-0.1.0/tests/test_observe.py +212 -0
- commissura-0.1.0/tests/test_opt_out.py +636 -0
- commissura-0.1.0/tests/test_opt_out_kinds.py +529 -0
- commissura-0.1.0/tests/test_packaging.py +432 -0
- commissura-0.1.0/tests/test_patient_identifiers.py +175 -0
- commissura-0.1.0/tests/test_permit_scope.py +523 -0
- commissura-0.1.0/tests/test_placeholder_identifier.py +297 -0
- commissura-0.1.0/tests/test_pseudonymise.py +253 -0
- commissura-0.1.0/tests/test_publish.py +782 -0
- commissura-0.1.0/tests/test_quasi_identifiers.py +226 -0
- commissura-0.1.0/tests/test_readme.py +138 -0
- commissura-0.1.0/tests/test_report.py +362 -0
- commissura-0.1.0/tests/test_report_identity.py +359 -0
- commissura-0.1.0/tests/test_reports.py +155 -0
- commissura-0.1.0/tests/test_residual_risk.py +254 -0
- commissura-0.1.0/tests/test_risk.py +242 -0
- commissura-0.1.0/tests/test_scrub_ordering.py +202 -0
- commissura-0.1.0/tests/test_shacl_conformance.py +346 -0
- commissura-0.1.0/tests/test_validate_edge_cases.py +379 -0
- commissura-0.1.0/tests/test_validate_rules.py +511 -0
- commissura-0.1.0/tests/test_vendored_shapes.py +227 -0
- commissura-0.1.0/tests/test_vocabulary.py +76 -0
- commissura-0.1.0/tests/test_walkthrough.py +355 -0
- commissura-0.1.0/tests/test_writer.py +136 -0
- commissura-0.1.0/third_party/PROVENANCE.json +59 -0
- commissura-0.1.0/third_party/dcat-ap/range.ttl +449 -0
- commissura-0.1.0/third_party/dcat-ap/shapes.ttl +746 -0
- commissura-0.1.0/third_party/healthdcat-ap/non-public-shapes.ttl +519 -0
- commissura-0.1.0/third_party/healthdcat-ap/range.ttl +131 -0
- commissura-0.1.0/uv.lock +1035 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Store and check out every text file with LF endings, on every platform.
|
|
2
|
+
#
|
|
3
|
+
# Without this, git on Windows converts LF to CRLF in the working copy and back
|
|
4
|
+
# on commit. For most projects that is invisible. Here it is not: the corpus
|
|
5
|
+
# writer exists to put exact bytes on disk, because every recorded PHI offset is
|
|
6
|
+
# a character position into a file, and HL7 v2 terminates its segments with a
|
|
7
|
+
# bare carriage return. A newline conversion applied to a fixture or an expected
|
|
8
|
+
# output would shift those offsets and the cause would be nearly impossible to
|
|
9
|
+
# see in a diff.
|
|
10
|
+
#
|
|
11
|
+
# Generated corpora are gitignored, so they are not what this protects today.
|
|
12
|
+
# It protects against the day somebody commits one as a fixture.
|
|
13
|
+
* text=auto eol=lf
|
|
14
|
+
|
|
15
|
+
# Binary files, declared so git never attempts a line-ending or diff conversion.
|
|
16
|
+
*.png binary
|
|
17
|
+
*.jpg binary
|
|
18
|
+
*.jpeg binary
|
|
19
|
+
*.gz binary
|
|
20
|
+
*.zip binary
|
|
21
|
+
*.pdf binary
|
|
22
|
+
*.nii binary
|
|
23
|
+
*.dcm binary
|
|
24
|
+
|
|
25
|
+
# Vendored third-party documents, stored and checked out byte for byte. `-text`
|
|
26
|
+
# switches off every line-ending conversion that the rule above would otherwise
|
|
27
|
+
# apply.
|
|
28
|
+
#
|
|
29
|
+
# Today this changes nothing: all four shape files are published with LF
|
|
30
|
+
# endings, so `eol=lf` would be a no-op on them. It is here because
|
|
31
|
+
# `third_party/PROVENANCE.json` records a SHA-256 per file and NOTICE states
|
|
32
|
+
# that each is unmodified, and CC BY 4.0 asks a redistributor to indicate
|
|
33
|
+
# whether changes were made. If a future refresh ever brings CRLF from
|
|
34
|
+
# upstream, normalisation would rewrite those bytes and make that statement
|
|
35
|
+
# untrue -- quietly, because the file would still parse. This rule means the
|
|
36
|
+
# repository holds what the publisher serves, whatever the publisher serves.
|
|
37
|
+
#
|
|
38
|
+
# Stated plainly because the first version of this comment claimed the files
|
|
39
|
+
# *were* CRLF and that the rule was fixing an active problem. It was not: the
|
|
40
|
+
# measurement behind it used an empty grep pattern, which matches every line.
|
|
41
|
+
# The rule survived the correction; the reason given for it did not, and this
|
|
42
|
+
# project has already recorded once what an unexamined reason costs.
|
|
43
|
+
third_party/** -text
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
# Cancel an in-flight run when a newer commit lands on the same branch: the
|
|
10
|
+
# older result is about code nobody will ship.
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ci-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
test:
|
|
17
|
+
# The declared floor is 3.11 and every version up to 3.14 is supported, so
|
|
18
|
+
# all four are run. Until now the floor was guaranteed only by ruff's
|
|
19
|
+
# target-version and mypy's python_version, which catch syntax and standard
|
|
20
|
+
# library APIs but not behaviour.
|
|
21
|
+
name: Python ${{ matrix.python-version }} on Ubuntu
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
strategy:
|
|
24
|
+
# Do not stop the other versions when one fails: on a first run the
|
|
25
|
+
# interesting question is which versions break, not that one did.
|
|
26
|
+
fail-fast: false
|
|
27
|
+
matrix:
|
|
28
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
|
|
32
|
+
- name: Install uv and Python ${{ matrix.python-version }}
|
|
33
|
+
uses: astral-sh/setup-uv@v6
|
|
34
|
+
with:
|
|
35
|
+
python-version: ${{ matrix.python-version }}
|
|
36
|
+
enable-cache: true
|
|
37
|
+
|
|
38
|
+
- name: Create the environment
|
|
39
|
+
run: uv venv
|
|
40
|
+
|
|
41
|
+
# The repository carries a tracked .python-version holding 3.14, and uv
|
|
42
|
+
# reads it when choosing an interpreter. If it won over the version
|
|
43
|
+
# setup-uv installed, all four jobs would run on 3.14 and show four green
|
|
44
|
+
# ticks that prove nothing about 3.11 — false confidence, which is worse
|
|
45
|
+
# than no test. setup-uv sets UV_PYTHON, which should take precedence, but
|
|
46
|
+
# that is exactly the kind of assumption worth turning into a check.
|
|
47
|
+
- name: Confirm the interpreter really is the matrix version
|
|
48
|
+
run: uv run python -c "import sys; assert sys.version.startswith('${{ matrix.python-version }}'), sys.version"
|
|
49
|
+
|
|
50
|
+
# From the lock, not resolved freely. These jobs are the gate on merging,
|
|
51
|
+
# and a gate has to fail for the commit in front of it and nothing else.
|
|
52
|
+
# `--locked` also fails when pyproject.toml and uv.lock disagree, which
|
|
53
|
+
# catches a dependency changed without refreshing the lock. The question
|
|
54
|
+
# "do today's dependencies still work" is a real one and is answered by
|
|
55
|
+
# the scheduled job below, where a failure blocks nobody.
|
|
56
|
+
- name: Install the project and its dev extras, from the lock
|
|
57
|
+
run: uv sync --locked --extra dev
|
|
58
|
+
|
|
59
|
+
- name: Lint
|
|
60
|
+
run: uv run ruff check .
|
|
61
|
+
|
|
62
|
+
- name: Check formatting
|
|
63
|
+
run: uv run ruff format --check .
|
|
64
|
+
|
|
65
|
+
- name: Type check
|
|
66
|
+
run: uv run mypy
|
|
67
|
+
|
|
68
|
+
# tests/test_shacl_conformance.py used to skip here, which meant this
|
|
69
|
+
# pipeline showed a green tick for the project's headline claim while
|
|
70
|
+
# never checking it. The shapes are vendored under third_party/ now, so
|
|
71
|
+
# the check runs on every push without reaching code.europa.eu — no
|
|
72
|
+
# dependency on a server nobody here controls, and no silent skip.
|
|
73
|
+
#
|
|
74
|
+
# The one remaining way for it to skip is pyshacl being unimportable, so
|
|
75
|
+
# that is asserted on its own line rather than left to a skip nobody
|
|
76
|
+
# reads. A test asserts pyshacl is still declared in the dev extra; this
|
|
77
|
+
# asserts it actually arrived.
|
|
78
|
+
- name: Confirm the conformance check can run
|
|
79
|
+
run: uv run python -c "import pyshacl"
|
|
80
|
+
|
|
81
|
+
- name: Test
|
|
82
|
+
run: uv run pytest
|
|
83
|
+
|
|
84
|
+
windows:
|
|
85
|
+
# The project claims to be cross-platform and was developed only on Windows.
|
|
86
|
+
# The Ubuntu job above is what makes that claim true; this one stops the
|
|
87
|
+
# opposite regression, where a fix for Linux breaks the platform the author
|
|
88
|
+
# actually works on. One version is enough for that.
|
|
89
|
+
name: Python 3.14 on Windows
|
|
90
|
+
runs-on: windows-latest
|
|
91
|
+
steps:
|
|
92
|
+
- uses: actions/checkout@v4
|
|
93
|
+
|
|
94
|
+
- name: Install uv and Python 3.14
|
|
95
|
+
uses: astral-sh/setup-uv@v6
|
|
96
|
+
with:
|
|
97
|
+
python-version: "3.14"
|
|
98
|
+
enable-cache: true
|
|
99
|
+
|
|
100
|
+
- name: Create the environment
|
|
101
|
+
run: uv venv
|
|
102
|
+
|
|
103
|
+
- name: Confirm the interpreter really is 3.14
|
|
104
|
+
run: uv run python -c "import sys; assert sys.version.startswith('3.14'), sys.version"
|
|
105
|
+
|
|
106
|
+
- name: Install the project and its dev extras, from the lock
|
|
107
|
+
run: uv sync --locked --extra dev
|
|
108
|
+
|
|
109
|
+
- name: Lint
|
|
110
|
+
run: uv run ruff check .
|
|
111
|
+
|
|
112
|
+
- name: Check formatting
|
|
113
|
+
run: uv run ruff format --check .
|
|
114
|
+
|
|
115
|
+
- name: Type check
|
|
116
|
+
run: uv run mypy
|
|
117
|
+
|
|
118
|
+
- name: Confirm the conformance check can run
|
|
119
|
+
run: uv run python -c "import pyshacl"
|
|
120
|
+
|
|
121
|
+
- name: Test
|
|
122
|
+
run: uv run pytest
|
|
123
|
+
|
|
124
|
+
reproducible:
|
|
125
|
+
# Now that `build` records a SHA-256 per file, reproducibility is a property
|
|
126
|
+
# that can be *proved* rather than assumed — and for a tool whose output is
|
|
127
|
+
# meant to be verified later, assuming it is not good enough. Each platform
|
|
128
|
+
# builds the same dataset from the same seed and the same key and uploads
|
|
129
|
+
# its manifest; the job below compares the digest lists.
|
|
130
|
+
#
|
|
131
|
+
# Three things have to match for this to mean anything, and all three are
|
|
132
|
+
# set here rather than left to chance: the seed, the key, and the output
|
|
133
|
+
# directory's *name* — `dct:identifier` is derived from it, so building into
|
|
134
|
+
# `ds_a` and `ds_b` produces two legitimately different documents. That was
|
|
135
|
+
# found by running the comparison locally before writing this job.
|
|
136
|
+
name: Reproducible bytes on ${{ matrix.os }}
|
|
137
|
+
runs-on: ${{ matrix.os }}
|
|
138
|
+
strategy:
|
|
139
|
+
fail-fast: false
|
|
140
|
+
matrix:
|
|
141
|
+
os: [ubuntu-latest, windows-latest]
|
|
142
|
+
steps:
|
|
143
|
+
- uses: actions/checkout@v4
|
|
144
|
+
|
|
145
|
+
- name: Install uv and Python 3.14
|
|
146
|
+
uses: astral-sh/setup-uv@v6
|
|
147
|
+
with:
|
|
148
|
+
python-version: "3.14"
|
|
149
|
+
enable-cache: true
|
|
150
|
+
|
|
151
|
+
- name: Create the environment
|
|
152
|
+
run: uv venv
|
|
153
|
+
|
|
154
|
+
- name: Install the project, from the lock
|
|
155
|
+
run: uv sync --locked
|
|
156
|
+
|
|
157
|
+
# A published test vector, not a secret: the bytes 0x00 to 0x1f in order,
|
|
158
|
+
# which is also what the test suite uses. It pseudonymises synthetic data
|
|
159
|
+
# in a throwaway runner and must never be used for anything else. Written
|
|
160
|
+
# here rather than committed, because `.gitignore` excludes `*.key` for a
|
|
161
|
+
# reason and this file should not exist outside a CI run.
|
|
162
|
+
- name: Write the reproducibility test key
|
|
163
|
+
shell: bash
|
|
164
|
+
run: |
|
|
165
|
+
printf '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f\n' > ci-test-vector.key
|
|
166
|
+
|
|
167
|
+
- name: Generate a corpus
|
|
168
|
+
shell: bash
|
|
169
|
+
run: uv run commissura generate --subjects 10 --seed 99 --defect-rate 0.3 --out ./raw
|
|
170
|
+
|
|
171
|
+
- name: Build the dataset
|
|
172
|
+
shell: bash
|
|
173
|
+
run: |
|
|
174
|
+
uv run commissura build ./raw --out ./dataset \
|
|
175
|
+
--key-file ./ci-test-vector.key \
|
|
176
|
+
--hdab "Agenzia Nazionale Sintetica per i Dati Sanitari" \
|
|
177
|
+
--publisher "IRCCS SINTETICO MAREBIANCO" \
|
|
178
|
+
--contact-point "dati@irccs-sintetico.invalid" \
|
|
179
|
+
--access-url "https://portale-hdab-sintetico.invalid/permessi"
|
|
180
|
+
|
|
181
|
+
- name: Confirm the dataset verifies against its own manifest
|
|
182
|
+
shell: bash
|
|
183
|
+
run: uv run commissura verify ./dataset --key-file ./ci-test-vector.key
|
|
184
|
+
|
|
185
|
+
- uses: actions/upload-artifact@v4
|
|
186
|
+
with:
|
|
187
|
+
name: manifest-${{ matrix.os }}
|
|
188
|
+
path: dataset/.deident/manifest.json
|
|
189
|
+
retention-days: 7
|
|
190
|
+
|
|
191
|
+
compare-platforms:
|
|
192
|
+
# The comparison itself. Separate job because it needs both manifests, and
|
|
193
|
+
# `needs` is the only way to be sure both exist.
|
|
194
|
+
name: Same bytes everywhere
|
|
195
|
+
runs-on: ubuntu-latest
|
|
196
|
+
needs: reproducible
|
|
197
|
+
steps:
|
|
198
|
+
- uses: actions/download-artifact@v4
|
|
199
|
+
with:
|
|
200
|
+
pattern: manifest-*
|
|
201
|
+
path: manifests
|
|
202
|
+
|
|
203
|
+
- name: Compare the per-file digests
|
|
204
|
+
shell: bash
|
|
205
|
+
run: |
|
|
206
|
+
python3 - <<'PY'
|
|
207
|
+
import json
|
|
208
|
+
import pathlib
|
|
209
|
+
import sys
|
|
210
|
+
|
|
211
|
+
# Only `integrity.files` is compared. The rest of the manifest
|
|
212
|
+
# legitimately differs between platforms: `generated_at` is a
|
|
213
|
+
# timestamp and `tool_versions` names the interpreter.
|
|
214
|
+
found = {}
|
|
215
|
+
for path in sorted(pathlib.Path("manifests").rglob("manifest.json")):
|
|
216
|
+
payload = json.loads(path.read_text(encoding="utf-8"))
|
|
217
|
+
found[path.parent.name] = payload["integrity"]["files"]
|
|
218
|
+
|
|
219
|
+
if len(found) < 2:
|
|
220
|
+
sys.exit(f"expected two manifests, found {sorted(found)}")
|
|
221
|
+
|
|
222
|
+
(first, baseline), *rest = sorted(found.items())
|
|
223
|
+
print(f"{first}: {len(baseline)} files")
|
|
224
|
+
failed = False
|
|
225
|
+
for name, other in rest:
|
|
226
|
+
print(f"{name}: {len(other)} files")
|
|
227
|
+
differing = sorted(
|
|
228
|
+
key for key in set(baseline) | set(other)
|
|
229
|
+
if baseline.get(key) != other.get(key)
|
|
230
|
+
)
|
|
231
|
+
if differing:
|
|
232
|
+
failed = True
|
|
233
|
+
print(f"\n{len(differing)} file(s) differ between {first} and {name}:")
|
|
234
|
+
for key in differing[:20]:
|
|
235
|
+
print(f" {key}")
|
|
236
|
+
print(f" {first}: {baseline.get(key, '(absent)')}")
|
|
237
|
+
print(f" {name}: {other.get(key, '(absent)')}")
|
|
238
|
+
if failed:
|
|
239
|
+
sys.exit("the same inputs did not produce the same bytes")
|
|
240
|
+
print("\nIdentical on every platform.")
|
|
241
|
+
PY
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
# INERT UNTIL SOMEBODY DELIBERATELY RUNS IT, AND THAT IS THE POINT.
|
|
4
|
+
#
|
|
5
|
+
# `workflow_dispatch` is the only trigger. There is deliberately no `push:
|
|
6
|
+
# tags:` and no `release:` trigger, because publishing to an index is
|
|
7
|
+
# irreversible — PyPI refuses to re-upload a filename it has already seen, and
|
|
8
|
+
# a yanked release is still downloadable by exact version. A workflow that
|
|
9
|
+
# fires on a tag turns `git push --tags` into a publication, which is a lot of
|
|
10
|
+
# consequence for a command people run without thinking.
|
|
11
|
+
#
|
|
12
|
+
# It also cannot work yet, and will fail honestly rather than silently if run
|
|
13
|
+
# before it can. Trusted publishing needs the index to be told which repository
|
|
14
|
+
# and which workflow file may publish this name:
|
|
15
|
+
#
|
|
16
|
+
# TestPyPI: https://test.pypi.org/manage/account/publishing/
|
|
17
|
+
# PyPI: https://pypi.org/manage/account/publishing/
|
|
18
|
+
#
|
|
19
|
+
# with owner `jonathanmanca`, repository `commissura`, workflow `publish.yml`
|
|
20
|
+
# and the environment name below. No API token is stored anywhere in this
|
|
21
|
+
# repository, and none should be: trusted publishing exchanges a short-lived
|
|
22
|
+
# OIDC identity for an upload token at the moment of upload.
|
|
23
|
+
#
|
|
24
|
+
# The declared environments are the second guard, and on this repository they
|
|
25
|
+
# are only half of one. A required reviewer would make every run wait for a
|
|
26
|
+
# human before it uploads anything -- but GitHub does not offer that rule for a
|
|
27
|
+
# private repository on this plan: "If you are on a GitHub Free, GitHub Pro, or
|
|
28
|
+
# GitHub Team plan, other deployment protection rules, such as a wait timer or
|
|
29
|
+
# required reviewers, are only available for public repositories." Measured on
|
|
30
|
+
# 2026-11-25, when the `testpypi` environment was created and that section of
|
|
31
|
+
# the settings page simply was not there.
|
|
32
|
+
#
|
|
33
|
+
# So a required reviewer belongs here and can only be configured once this
|
|
34
|
+
# repository is public; until it is, the environment names the claim the index
|
|
35
|
+
# trusts and nothing else, and the only human gate is the one above -- a
|
|
36
|
+
# `workflow_dispatch` run can be started only by somebody with write access.
|
|
37
|
+
#
|
|
38
|
+
# Rehearse on TestPyPI first, which is why it is the default and the only
|
|
39
|
+
# choice a careless click produces.
|
|
40
|
+
|
|
41
|
+
on:
|
|
42
|
+
workflow_dispatch:
|
|
43
|
+
inputs:
|
|
44
|
+
index:
|
|
45
|
+
description: Which index to upload to. Rehearse on TestPyPI first.
|
|
46
|
+
required: true
|
|
47
|
+
default: testpypi
|
|
48
|
+
type: choice
|
|
49
|
+
options:
|
|
50
|
+
- testpypi
|
|
51
|
+
- pypi
|
|
52
|
+
|
|
53
|
+
jobs:
|
|
54
|
+
verify:
|
|
55
|
+
# The same gate as every push, run again here, because a release is the one
|
|
56
|
+
# artefact this project cannot take back. It costs three minutes once per
|
|
57
|
+
# release and it is the cheapest part of the whole operation.
|
|
58
|
+
name: Everything still passes
|
|
59
|
+
runs-on: ubuntu-latest
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@v4
|
|
62
|
+
|
|
63
|
+
- name: Install uv and Python 3.11
|
|
64
|
+
uses: astral-sh/setup-uv@v6
|
|
65
|
+
with:
|
|
66
|
+
python-version: "3.11"
|
|
67
|
+
enable-cache: true
|
|
68
|
+
|
|
69
|
+
- name: Create the environment
|
|
70
|
+
run: uv venv
|
|
71
|
+
|
|
72
|
+
- name: Install the project and its dev extras, from the lock
|
|
73
|
+
run: uv sync --locked --extra dev
|
|
74
|
+
|
|
75
|
+
- name: Lint
|
|
76
|
+
run: uv run ruff check .
|
|
77
|
+
|
|
78
|
+
- name: Check formatting
|
|
79
|
+
run: uv run ruff format --check .
|
|
80
|
+
|
|
81
|
+
- name: Type check
|
|
82
|
+
run: uv run mypy
|
|
83
|
+
|
|
84
|
+
- name: Confirm the conformance check can run
|
|
85
|
+
run: uv run python -c "import pyshacl"
|
|
86
|
+
|
|
87
|
+
- name: Test
|
|
88
|
+
run: uv run pytest
|
|
89
|
+
|
|
90
|
+
build:
|
|
91
|
+
name: Build and inspect the artefacts
|
|
92
|
+
runs-on: ubuntu-latest
|
|
93
|
+
needs: verify
|
|
94
|
+
steps:
|
|
95
|
+
- uses: actions/checkout@v4
|
|
96
|
+
|
|
97
|
+
- name: Install uv and Python 3.11
|
|
98
|
+
uses: astral-sh/setup-uv@v6
|
|
99
|
+
with:
|
|
100
|
+
python-version: "3.11"
|
|
101
|
+
enable-cache: true
|
|
102
|
+
|
|
103
|
+
- name: Build the sdist and the wheel
|
|
104
|
+
run: uv build
|
|
105
|
+
|
|
106
|
+
# `tests/test_packaging.py` already asserts what each artefact must and
|
|
107
|
+
# must not contain, and the job above ran it. This is the metadata half,
|
|
108
|
+
# which that test does not cover: `twine check` renders the long
|
|
109
|
+
# description the way the index will and fails on markup the index would
|
|
110
|
+
# reject. A README that does not render is not a defect worth discovering
|
|
111
|
+
# on an immutable upload.
|
|
112
|
+
- name: Check the metadata the way the index will
|
|
113
|
+
run: uv run --with twine --no-project twine check dist/*
|
|
114
|
+
|
|
115
|
+
# Installed from the wheel, in an environment that has never seen the
|
|
116
|
+
# checkout, and then driven. This is the whole of the "deployable by a
|
|
117
|
+
# stranger" claim: not that the code is good, but that somebody who has
|
|
118
|
+
# only the artefact can run it.
|
|
119
|
+
- name: Install the wheel somewhere that has no source tree
|
|
120
|
+
run: |
|
|
121
|
+
mkdir -p /tmp/stranger && cd /tmp/stranger
|
|
122
|
+
uv venv --python 3.11 .venv
|
|
123
|
+
uv pip install --python .venv --no-cache "$GITHUB_WORKSPACE"/dist/*.whl
|
|
124
|
+
|
|
125
|
+
- name: Run the README's walkthrough from the installed wheel
|
|
126
|
+
run: |
|
|
127
|
+
cd /tmp/stranger
|
|
128
|
+
C=.venv/bin/commissura
|
|
129
|
+
"$C" --version
|
|
130
|
+
"$C" generate --subjects 10 --seed 42 --defect-rate 0.2 --out ./raw
|
|
131
|
+
"$C" keygen --out ./k.key
|
|
132
|
+
"$C" build ./raw --out ./dataset --key-file ./k.key \
|
|
133
|
+
--hdab "Agenzia Nazionale Sintetica per i Dati Sanitari" \
|
|
134
|
+
--publisher "IRCCS SINTETICO MAREBIANCO" \
|
|
135
|
+
--contact-point "dati@irccs-sintetico.invalid" \
|
|
136
|
+
--access-url "https://portale-hdab-sintetico.invalid/permessi"
|
|
137
|
+
"$C" validate ./dataset
|
|
138
|
+
"$C" verify ./dataset --key-file ./k.key
|
|
139
|
+
"$C" measure ./raw ./dataset
|
|
140
|
+
|
|
141
|
+
- uses: actions/upload-artifact@v4
|
|
142
|
+
with:
|
|
143
|
+
name: distributions
|
|
144
|
+
path: dist/*
|
|
145
|
+
retention-days: 7
|
|
146
|
+
|
|
147
|
+
publish:
|
|
148
|
+
name: Upload to ${{ inputs.index }}
|
|
149
|
+
runs-on: ubuntu-latest
|
|
150
|
+
needs: build
|
|
151
|
+
# Names the environment the index was told to trust, and the place a
|
|
152
|
+
# required reviewer goes. Without one a run does not stop here at all --
|
|
153
|
+
# see the note at the top for why there may not be one.
|
|
154
|
+
environment: ${{ inputs.index }}
|
|
155
|
+
permissions:
|
|
156
|
+
# Required for trusted publishing, and the reason no token is stored.
|
|
157
|
+
# Nothing else in this workflow needs a permission, so nothing else has
|
|
158
|
+
# one.
|
|
159
|
+
id-token: write
|
|
160
|
+
steps:
|
|
161
|
+
- uses: actions/download-artifact@v4
|
|
162
|
+
with:
|
|
163
|
+
name: distributions
|
|
164
|
+
path: dist
|
|
165
|
+
|
|
166
|
+
- name: Upload
|
|
167
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
168
|
+
with:
|
|
169
|
+
repository-url: >-
|
|
170
|
+
${{ inputs.index == 'pypi'
|
|
171
|
+
&& 'https://upload.pypi.org/legacy/'
|
|
172
|
+
|| 'https://test.pypi.org/legacy/' }}
|
|
173
|
+
print-hash: true
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
name: Upstream dependencies
|
|
2
|
+
|
|
3
|
+
# A canary, not a gate. `ci.yml` installs from uv.lock so that a red tick means
|
|
4
|
+
# the commit in front of it broke something. This job deliberately ignores the
|
|
5
|
+
# lock and resolves freely, which answers the other question: do today's
|
|
6
|
+
# published versions of typer, pydantic, ruff, mypy and pyshacl still work with
|
|
7
|
+
# this code? That question is worth an answer and is worth nobody's merge being
|
|
8
|
+
# blocked by it, so it lives in its own workflow with its own badge.
|
|
9
|
+
#
|
|
10
|
+
# Separate file rather than another job in ci.yml on purpose: a failure here
|
|
11
|
+
# would otherwise turn the CI badge red, and the badge would stop meaning "this
|
|
12
|
+
# code is good" and start meaning "something somewhere moved".
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
schedule:
|
|
16
|
+
# Monday, 06:00 UTC. GitHub disables scheduled workflows after 60 days with
|
|
17
|
+
# no repository activity, so a long quiet spell switches this off silently;
|
|
18
|
+
# workflow_dispatch is here so it can always be run by hand.
|
|
19
|
+
- cron: "0 6 * * 1"
|
|
20
|
+
workflow_dispatch:
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
unlocked:
|
|
24
|
+
name: Freely resolved on Python ${{ matrix.python-version }}
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
strategy:
|
|
27
|
+
# The floor and the ceiling. An upstream package dropping 3.11 support is
|
|
28
|
+
# one of the likelier ways this breaks, and it would show on 3.11 alone.
|
|
29
|
+
fail-fast: false
|
|
30
|
+
matrix:
|
|
31
|
+
python-version: ["3.11", "3.14"]
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
|
|
35
|
+
- name: Install uv and Python ${{ matrix.python-version }}
|
|
36
|
+
uses: astral-sh/setup-uv@v6
|
|
37
|
+
with:
|
|
38
|
+
python-version: ${{ matrix.python-version }}
|
|
39
|
+
# No cache: a cached resolution is the opposite of the point.
|
|
40
|
+
enable-cache: false
|
|
41
|
+
|
|
42
|
+
- name: Create the environment
|
|
43
|
+
run: uv venv
|
|
44
|
+
|
|
45
|
+
- name: Confirm the interpreter really is the matrix version
|
|
46
|
+
run: uv run python -c "import sys; assert sys.version.startswith('${{ matrix.python-version }}'), sys.version"
|
|
47
|
+
|
|
48
|
+
- name: Install the newest versions the constraints allow
|
|
49
|
+
run: uv pip install -e ".[dev]" --upgrade
|
|
50
|
+
|
|
51
|
+
- name: Record what was resolved
|
|
52
|
+
# So that a failure can be read without re-running it: the log says
|
|
53
|
+
# which versions were in play.
|
|
54
|
+
run: uv pip list
|
|
55
|
+
|
|
56
|
+
- name: Lint
|
|
57
|
+
run: uv run ruff check .
|
|
58
|
+
|
|
59
|
+
- name: Check formatting
|
|
60
|
+
run: uv run ruff format --check .
|
|
61
|
+
|
|
62
|
+
- name: Type check
|
|
63
|
+
run: uv run mypy
|
|
64
|
+
|
|
65
|
+
- name: Test
|
|
66
|
+
run: uv run pytest
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Virtual environment and interpreter caches
|
|
2
|
+
.venv/
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
|
|
6
|
+
# Tool caches
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
.mypy_cache/
|
|
9
|
+
.ruff_cache/
|
|
10
|
+
|
|
11
|
+
# Coverage output
|
|
12
|
+
.coverage
|
|
13
|
+
.coverage.*
|
|
14
|
+
coverage.xml
|
|
15
|
+
/htmlcov/
|
|
16
|
+
|
|
17
|
+
# Build artefacts. Anchored with a leading slash: without it, a trailing-slash
|
|
18
|
+
# pattern matches a directory of that name at any depth, and `build/` silently
|
|
19
|
+
# excluded src/commissura/build/ from version control for three commits.
|
|
20
|
+
# Every plain directory name below is anchored for the same reason.
|
|
21
|
+
/dist/
|
|
22
|
+
/build/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
|
|
25
|
+
# Pseudonymisation keys. Never commit one: the whole design rests on the key
|
|
26
|
+
# staying outside the dataset, and a key in a repository is a key in every
|
|
27
|
+
# clone, every fork and every mirror, permanently.
|
|
28
|
+
*.key
|
|
29
|
+
*.pem
|
|
30
|
+
|
|
31
|
+
# Generated corpora and datasets. Reproducible from a seed, so committing them
|
|
32
|
+
# adds weight without adding information — and a raw corpus deliberately
|
|
33
|
+
# contains synthetic identifiers, which do not belong in version control even
|
|
34
|
+
# when they are fake.
|
|
35
|
+
/raw/
|
|
36
|
+
/dataset/
|
|
37
|
+
/corpus/
|
|
38
|
+
|
|
39
|
+
# Downloaded reference material (specifications, authority lists). Someone
|
|
40
|
+
# else's documents, fetched on demand and recorded by URL in CLAUDE.md.
|
|
41
|
+
/reference/
|
|
42
|
+
|
|
43
|
+
# Editor and OS noise
|
|
44
|
+
.vscode/
|
|
45
|
+
.idea/
|
|
46
|
+
*.swp
|
|
47
|
+
.DS_Store
|
|
48
|
+
Thumbs.db
|
|
49
|
+
|
|
50
|
+
# The brief, kept out of the repository on purpose. It is an instruction
|
|
51
|
+
# document as much as a project memory, and the author does not want it
|
|
52
|
+
# available to be copied as one. It stays on disk and is still the project's
|
|
53
|
+
# memory; it is simply not versioned here. The consequence is recorded in its
|
|
54
|
+
# own decision log: the command list it carries is no longer mechanically
|
|
55
|
+
# checked, and that guard moved to the README's command table, which is in the
|
|
56
|
+
# repository and is what a stranger reads.
|
|
57
|
+
/CLAUDE.md
|
|
58
|
+
|
|
59
|
+
# Audit and remediation paperwork, kept out of the repository on purpose.
|
|
60
|
+
# Internal working documents, not part of what a stranger reads in order to use
|
|
61
|
+
# the tool -- the same reason CLAUDE.md is excluded above. The decisions they
|
|
62
|
+
# recorded live in that file's log, which is where this project keeps decisions.
|
|
63
|
+
#
|
|
64
|
+
# The first version of this comment gave a security reason instead, and it did
|
|
65
|
+
# not hold: it called the reproduction steps "a recipe against any dataset built
|
|
66
|
+
# before they were fixed", when the findings were already closed, no release
|
|
67
|
+
# exists, no dataset was ever built outside one machine, and the documents remain
|
|
68
|
+
# readable in the history at cf57232 and 282bd91 regardless. A rule whose stated
|
|
69
|
+
# reason does not survive reading is worse than no rule, because the next person
|
|
70
|
+
# to weigh it has to work out that the justification was wrong before they can
|
|
71
|
+
# decide whether the rule is.
|
|
72
|
+
#
|
|
73
|
+
# Listed here rather than merely deleted because `git add -A` is how two of them
|
|
74
|
+
# got committed, in a commit whose message did not mention them.
|
|
75
|
+
/SECURITY_AUDIT.md
|
|
76
|
+
/ENGINEERING_REVIEW.md
|
|
77
|
+
/REMEDIATION_REPORT.md
|
|
78
|
+
/IDENTITY_RESOLUTION.md
|
|
79
|
+
/HARDENING_CHANGELOG.md
|
|
80
|
+
|
|
81
|
+
# The TEHDAS2 analysis set, excluded for the same reason as the five above:
|
|
82
|
+
# internal working documents, not part of what a stranger reads in order to use
|
|
83
|
+
# the tool. The gap matrix, the risk register, the target architecture, the
|
|
84
|
+
# remediation plan, the traceability matrix and the implementation report are
|
|
85
|
+
# how this project decided what to build; they are not how anybody uses it.
|
|
86
|
+
#
|
|
87
|
+
# They were committed in e45e704 before that was decided, so `git show
|
|
88
|
+
# e45e704:docs/TEHDAS2_GAP_ANALYSIS.md` still prints one in any clone. That is
|
|
89
|
+
# deliberate and not an oversight: the decision of 2026-11-16 settled that this
|
|
90
|
+
# project does not rewrite its history to remove internal paperwork, because the
|
|
91
|
+
# cost -- every commit SHA changed, every clone invalidated -- is certain while
|
|
92
|
+
# the risk is nil. A `git rm --cached` changes what HEAD carries and nothing
|
|
93
|
+
# else, and nobody should read the current tree and conclude otherwise.
|
|
94
|
+
#
|
|
95
|
+
# Not a security measure, and saying so matters: the comment above records what
|
|
96
|
+
# happened the last time a reason that merely sounded like one went unexamined.
|
|
97
|
+
/docs/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to `commissura`, newest first. Versions follow
|
|
4
|
+
[semantic versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
+
|
|
6
|
+
Three other version numbers travel inside the output and move independently of
|
|
7
|
+
this one, because a consumer needs to know which of them changed:
|
|
8
|
+
`.deident/manifest.json` and `.deident/risk_report.json` each declare their own
|
|
9
|
+
schema version, the dataset layout declares a third, and the de-identification
|
|
10
|
+
rules declare a fourth. A release that moves any of them says so below.
|
|
11
|
+
|
|
12
|
+
## 0.1.0 — 2026-11-25
|
|
13
|
+
|
|
14
|
+
First release.
|
|
15
|
+
|
|
16
|
+
### The tool
|
|
17
|
+
|
|
18
|
+
- Eleven commands, each with `--json`: `generate`, `defects`, `validate`,
|
|
19
|
+
`rules`, `keygen`, `key-info`, `build`, `risk`, `verify`, `measure`, `whois`.
|
|
20
|
+
- Reads HL7 v2 laboratory messages, free-text reports, DICOM imaging metadata
|
|
21
|
+
as JSON, and HL7 Italia CDA R2 documents — laboratory, radiology, discharge
|
|
22
|
+
letter, pathology, outpatient specialist care and the patient summary.
|
|
23
|
+
- Writes a BIDS-compatible dataset extended with `lab/` and `reports/`, a
|
|
24
|
+
HealthDCAT-AP Release 8 dataset description, a de-identification manifest and
|
|
25
|
+
a re-identification risk report.
|
|
26
|
+
- Pseudonymisation is HMAC-SHA256 from one secret key, domain-separated per
|
|
27
|
+
purpose and consistent across modalities. The key never enters the dataset
|
|
28
|
+
and is never a command-line argument.
|
|
29
|
+
- Disclosure controls the holder chooses: `--permit` scopes pseudonyms to one
|
|
30
|
+
data permit, `--age-band` generalises participant ages, and
|
|
31
|
+
`--exclude-subjects` acts on an objection.
|
|
32
|
+
- `measure` compares the generator's ground-truth annotations against the built
|
|
33
|
+
dataset and reports recall, so the de-identification is measured rather than
|
|
34
|
+
asserted.
|
|
35
|
+
|
|
36
|
+
### What it does not do
|
|
37
|
+
|
|
38
|
+
- **Pseudonymisation, not anonymisation.** The output is still personal data.
|
|
39
|
+
`risk` reports k over the quasi-identifiers it can score and names the
|
|
40
|
+
channels it cannot; it certifies nothing.
|
|
41
|
+
- Free-text identity parsing is written against the labels this project's own
|
|
42
|
+
generator produces. A hospital whose template writes something else needs
|
|
43
|
+
that table edited in source, which means editing and reinstalling rather than
|
|
44
|
+
configuring.
|
|
45
|
+
- Day offsets keep intervals exact, which is a documented re-identification
|
|
46
|
+
channel kept open deliberately. The README says which side it takes.
|
|
47
|
+
|
|
48
|
+
### Schema versions carried by this release
|
|
49
|
+
|
|
50
|
+
- Manifest `7.2.0`, risk report `1.2.0`, dataset layout `1.1.0`,
|
|
51
|
+
de-identification rules `1.2.0`.
|