claimproofkit 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. claimproofkit-0.1.0/LICENSE +203 -0
  2. claimproofkit-0.1.0/NOTICE +6 -0
  3. claimproofkit-0.1.0/PKG-INFO +95 -0
  4. claimproofkit-0.1.0/README.md +67 -0
  5. claimproofkit-0.1.0/claimproofkit/__init__.py +95 -0
  6. claimproofkit-0.1.0/claimproofkit/_text.py +94 -0
  7. claimproofkit-0.1.0/claimproofkit/benchmark.py +407 -0
  8. claimproofkit-0.1.0/claimproofkit/cli.py +136 -0
  9. claimproofkit-0.1.0/claimproofkit/extractor.py +113 -0
  10. claimproofkit-0.1.0/claimproofkit/identity.py +134 -0
  11. claimproofkit-0.1.0/claimproofkit/models.py +133 -0
  12. claimproofkit-0.1.0/claimproofkit/pipeline.py +145 -0
  13. claimproofkit-0.1.0/claimproofkit/provenance.py +279 -0
  14. claimproofkit-0.1.0/claimproofkit/py.typed +0 -0
  15. claimproofkit-0.1.0/claimproofkit/report.py +219 -0
  16. claimproofkit-0.1.0/claimproofkit/verifier.py +239 -0
  17. claimproofkit-0.1.0/claimproofkit.egg-info/PKG-INFO +95 -0
  18. claimproofkit-0.1.0/claimproofkit.egg-info/SOURCES.txt +27 -0
  19. claimproofkit-0.1.0/claimproofkit.egg-info/dependency_links.txt +1 -0
  20. claimproofkit-0.1.0/claimproofkit.egg-info/entry_points.txt +2 -0
  21. claimproofkit-0.1.0/claimproofkit.egg-info/requires.txt +3 -0
  22. claimproofkit-0.1.0/claimproofkit.egg-info/top_level.txt +1 -0
  23. claimproofkit-0.1.0/pyproject.toml +45 -0
  24. claimproofkit-0.1.0/setup.cfg +4 -0
  25. claimproofkit-0.1.0/tests/test_benchmark_metrics.py +81 -0
  26. claimproofkit-0.1.0/tests/test_conformance.py +21 -0
  27. claimproofkit-0.1.0/tests/test_identity_and_bridge.py +135 -0
  28. claimproofkit-0.1.0/tests/test_swift_parity_regressions.py +116 -0
  29. claimproofkit-0.1.0/tests/test_verifier.py +97 -0
@@ -0,0 +1,203 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on or derived from the Work and for which
42
+ the editorial revisions, annotations, elaborations, or other
43
+ modifications represent, as a whole, an original work of authorship.
44
+ For the purposes of this License, Derivative Works shall not include
45
+ works that remain separable from, or merely link (or bind by name) to
46
+ the interfaces of, the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf
53
+ of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written
55
+ communication sent to the Licensor or its representatives, including
56
+ but not limited to communication on electronic mailing lists, source
57
+ code control systems, and issue tracking systems that are managed by,
58
+ or on behalf of, the Licensor for the purpose of discussing and
59
+ improving the Work, but excluding communication that is conspicuously
60
+ marked or otherwise designated in writing by the copyright owner as
61
+ "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 do not
118
+ modify the License. You may add Your own attribution notices
119
+ within Derivative Works that You distribute, alongside or as an
120
+ addendum to the NOTICE text from the Work, provided that such
121
+ additional attribution notices cannot be construed as modifying
122
+ 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 such modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies
129
+ with 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
134
+ of 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
142
+ the 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
151
+ the appropriateness of using or redistributing the Work and assume
152
+ any risks associated with Your exercise of permissions under this
153
+ License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor
159
+ be liable to You for damages, including any direct, indirect,
160
+ special, incidental, or consequential damages of any character
161
+ arising as a result of this License or out of the use or inability
162
+ to use the Work (including but not limited to damages for loss
163
+ of goodwill, work stoppage, computer failure or malfunction, or
164
+ any and all other commercial damages or losses), even if such
165
+ Contributor has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by
176
+ reason of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a file
187
+ or class name and description of purpose be included on the same
188
+ "printed page" as the copyright notice for easier identification
189
+ within third-party archives.
190
+
191
+ Copyright 2026 Daniel Kissel
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ ClaimProofKitPython
2
+ Copyright 2026 Daniel Kissel
3
+
4
+ This project is licensed under the Apache License, Version 2.0.
5
+ The Apache License does not grant trademark rights except as expressly stated
6
+ therein. The ClaimProofKit name and logos may not be used to imply endorsement.
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.4
2
+ Name: claimproofkit
3
+ Version: 0.1.0
4
+ Summary: Apache-2.0 licensed, evidence-bound claim verification that blocks generated documents whose material claims the supplied evidence does not support. Python implementation of Claim Proof Specification v1, in locked parity with the Swift reference implementation.
5
+ Author: ClaimProofKit
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Therealdk8890/ClaimProofKitPython
8
+ Project-URL: Reference-Implementation, https://github.com/Therealdk8890/ClaimProofKit
9
+ Keywords: verification,claims,evidence,hallucination,provenance,legal
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ License-File: NOTICE
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # ClaimProofKit — Python implementation
30
+
31
+ **Apache-2.0 licensed** · Evidence-bound claim verification · Zero runtime dependencies
32
+
33
+ ClaimProofKit implements **Claim Proof Specification v1**: it checks whether the material claims in a generated document are supported by supplied evidence, and blocks publication when claims are unsupported or when no material claims can be extracted. It uses only the Python standard library at runtime.
34
+
35
+ The Swift [ClaimProofKit](https://github.com/Therealdk8890/ClaimProofKit) is the reference implementation. This Python implementation is held in **locked parity** with it through the golden vectors under `conformance/vectors`. Fingerprints, verifier verdicts, and canonical payload bytes are checked across both implementations.
36
+
37
+ ## License
38
+
39
+ ClaimProofKit is licensed under the [Apache License, Version 2.0](LICENSE). You may use, modify, distribute, and include it in commercial products subject to the license terms. **No separate production-use license is required.** See [NOTICE](NOTICE) and [Licensing and commercial use](COMMERCIAL_LICENSING.md).
40
+
41
+ The Apache-2.0 license applies to the code in this repository; it does not grant rights to project trademarks or imply endorsement.
42
+
43
+ ## Install and test
44
+
45
+ ```sh
46
+ pip install -e ".[dev]"
47
+ pytest
48
+ python conformance/run_conformance.py
49
+ ```
50
+
51
+ ## Verify a document
52
+
53
+ A document with no extractable material claims is **not** considered safe to publish. A successful verification gate requires at least one claim, and every extracted claim must have an approved verdict. This avoids treating an empty or unrecognized document as verified by vacuous success.
54
+
55
+ ```python
56
+ from claimproofkit import ClaimVerifier, EvidencePassage, SourceType
57
+
58
+ evidence = [
59
+ EvidencePassage(
60
+ id="order-1",
61
+ source="Scheduling Order",
62
+ source_type=SourceType.COURT_RECORD,
63
+ text="The court denied the request for an extension.",
64
+ )
65
+ ]
66
+ report = ClaimVerifier().verify_document(
67
+ "The court denied the request for an extension.", evidence
68
+ )
69
+ assert report.is_safe_to_publish
70
+ ```
71
+
72
+ The CLI exposes the same command semantics and exit codes as the Swift binary (0 published, 2 blocked, 3 benchmark gate failed, 64 usage, 65 unreadable input, 73 trace write failed):
73
+
74
+ ```sh
75
+ claimproofkit verify input.json [--provenance trace.json]
76
+ claimproofkit benchmark corpus.json [--json]
77
+ ```
78
+
79
+ ## Working with DProvenanceKit
80
+
81
+ `claimproofkit.provenance` exports a verification run as a DProvenanceKit-compatible trace, identical to the Swift bridge's output: stable `cpk_*` event vocabulary, canonical payload bytes (Trace Specification v1 §2), lineage edges, and the §5 run fingerprint.
82
+
83
+ ```python
84
+ from claimproofkit import ProvenanceExporter, VerificationPolicy
85
+
86
+ trace = ProvenanceExporter().trace(report, VerificationPolicy())
87
+ trace.events_json() # decodes as [TraceEvent<AnyTraceableEvent>] in Swift DProvenanceKit
88
+ trace.manifest_json() # full manifest with fingerprints and edges
89
+ ```
90
+
91
+ The conformance runner proves the fingerprint against the real Python [dprovenancekit](https://github.com/Therealdk8890/DProvenanceKitPython) package when it is importable: recording the trace through its SQLite store reproduces the bridge's run fingerprint byte-for-byte. The same trace fingerprints identically in Swift ClaimProofKit, Swift DProvenanceKit, and Python dprovenancekit.
92
+
93
+ ## Changing locked behavior
94
+
95
+ Specification changes originate in the Swift repo ([`Docs/PROOF_SPEC_V1.md`](https://github.com/Therealdk8890/ClaimProofKit/blob/main/Docs/PROOF_SPEC_V1.md)): bump the spec/verifier version there, regenerate vectors, then re-sync here with `conformance/sync-vectors.sh` and update this implementation to conform.
@@ -0,0 +1,67 @@
1
+ # ClaimProofKit — Python implementation
2
+
3
+ **Apache-2.0 licensed** · Evidence-bound claim verification · Zero runtime dependencies
4
+
5
+ ClaimProofKit implements **Claim Proof Specification v1**: it checks whether the material claims in a generated document are supported by supplied evidence, and blocks publication when claims are unsupported or when no material claims can be extracted. It uses only the Python standard library at runtime.
6
+
7
+ The Swift [ClaimProofKit](https://github.com/Therealdk8890/ClaimProofKit) is the reference implementation. This Python implementation is held in **locked parity** with it through the golden vectors under `conformance/vectors`. Fingerprints, verifier verdicts, and canonical payload bytes are checked across both implementations.
8
+
9
+ ## License
10
+
11
+ ClaimProofKit is licensed under the [Apache License, Version 2.0](LICENSE). You may use, modify, distribute, and include it in commercial products subject to the license terms. **No separate production-use license is required.** See [NOTICE](NOTICE) and [Licensing and commercial use](COMMERCIAL_LICENSING.md).
12
+
13
+ The Apache-2.0 license applies to the code in this repository; it does not grant rights to project trademarks or imply endorsement.
14
+
15
+ ## Install and test
16
+
17
+ ```sh
18
+ pip install -e ".[dev]"
19
+ pytest
20
+ python conformance/run_conformance.py
21
+ ```
22
+
23
+ ## Verify a document
24
+
25
+ A document with no extractable material claims is **not** considered safe to publish. A successful verification gate requires at least one claim, and every extracted claim must have an approved verdict. This avoids treating an empty or unrecognized document as verified by vacuous success.
26
+
27
+ ```python
28
+ from claimproofkit import ClaimVerifier, EvidencePassage, SourceType
29
+
30
+ evidence = [
31
+ EvidencePassage(
32
+ id="order-1",
33
+ source="Scheduling Order",
34
+ source_type=SourceType.COURT_RECORD,
35
+ text="The court denied the request for an extension.",
36
+ )
37
+ ]
38
+ report = ClaimVerifier().verify_document(
39
+ "The court denied the request for an extension.", evidence
40
+ )
41
+ assert report.is_safe_to_publish
42
+ ```
43
+
44
+ The CLI exposes the same command semantics and exit codes as the Swift binary (0 published, 2 blocked, 3 benchmark gate failed, 64 usage, 65 unreadable input, 73 trace write failed):
45
+
46
+ ```sh
47
+ claimproofkit verify input.json [--provenance trace.json]
48
+ claimproofkit benchmark corpus.json [--json]
49
+ ```
50
+
51
+ ## Working with DProvenanceKit
52
+
53
+ `claimproofkit.provenance` exports a verification run as a DProvenanceKit-compatible trace, identical to the Swift bridge's output: stable `cpk_*` event vocabulary, canonical payload bytes (Trace Specification v1 §2), lineage edges, and the §5 run fingerprint.
54
+
55
+ ```python
56
+ from claimproofkit import ProvenanceExporter, VerificationPolicy
57
+
58
+ trace = ProvenanceExporter().trace(report, VerificationPolicy())
59
+ trace.events_json() # decodes as [TraceEvent<AnyTraceableEvent>] in Swift DProvenanceKit
60
+ trace.manifest_json() # full manifest with fingerprints and edges
61
+ ```
62
+
63
+ The conformance runner proves the fingerprint against the real Python [dprovenancekit](https://github.com/Therealdk8890/DProvenanceKitPython) package when it is importable: recording the trace through its SQLite store reproduces the bridge's run fingerprint byte-for-byte. The same trace fingerprints identically in Swift ClaimProofKit, Swift DProvenanceKit, and Python dprovenancekit.
64
+
65
+ ## Changing locked behavior
66
+
67
+ Specification changes originate in the Swift repo ([`Docs/PROOF_SPEC_V1.md`](https://github.com/Therealdk8890/ClaimProofKit/blob/main/Docs/PROOF_SPEC_V1.md)): bump the spec/verifier version there, regenerate vectors, then re-sync here with `conformance/sync-vectors.sh` and update this implementation to conform.
@@ -0,0 +1,95 @@
1
+ # Copyright 2026 Daniel Kissel
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """claimproofkit — evidence-bound claim verification.
5
+
6
+ Python implementation of Claim Proof Specification v1, in locked parity with
7
+ the Swift ClaimProofKit (the reference implementation). Parity is proved by
8
+ the conformance runner under ``conformance/``, which executes the same golden
9
+ vectors the Swift repo locks in CI.
10
+ """
11
+
12
+ from .extractor import ClaimExtractor
13
+ from .identity import (
14
+ SPEC_VERSION,
15
+ VERIFIER_IDENTIFIER,
16
+ VERIFIER_VERSION,
17
+ canonical_json,
18
+ evidence_content_fingerprint,
19
+ policy_fingerprint,
20
+ report_fingerprint,
21
+ )
22
+ from .models import (
23
+ APPROVED_STATUSES,
24
+ Claim,
25
+ ClaimType,
26
+ ClaimVerdict,
27
+ EvidenceMatch,
28
+ EvidencePassage,
29
+ ProofReport,
30
+ SourceType,
31
+ SupportStatus,
32
+ VerificationPolicy,
33
+ make_claim_fingerprint,
34
+ )
35
+ from .provenance import (
36
+ BRIDGE_VERSION,
37
+ CLAIM_EXTRACTED,
38
+ CLAIM_VERIFIED,
39
+ REPORT_FINALIZED,
40
+ ProvenanceEdge,
41
+ ProvenanceEventEnvelope,
42
+ ProvenanceExporter,
43
+ ProvenanceTrace,
44
+ run_fingerprint_of,
45
+ )
46
+ from .pipeline import (
47
+ AtomicClaimExtracting,
48
+ ClaimEntailmentVerifying,
49
+ ConservativeProofPolicy,
50
+ DefaultTrustReportGenerator,
51
+ Disposition,
52
+ EvidenceRetrieving,
53
+ LexicalEntailmentVerifier,
54
+ PassthroughEvidenceRetriever,
55
+ PipelineResult,
56
+ ProofDecision,
57
+ ProofPolicyEvaluating,
58
+ TrustReportGenerating,
59
+ VerificationPipeline,
60
+ )
61
+ from .verifier import ClaimVerifier
62
+
63
+ __version__ = "0.1.0"
64
+
65
+ __all__ = [
66
+ "APPROVED_STATUSES",
67
+ "BRIDGE_VERSION",
68
+ "CLAIM_EXTRACTED",
69
+ "CLAIM_VERIFIED",
70
+ "REPORT_FINALIZED",
71
+ "SPEC_VERSION",
72
+ "VERIFIER_IDENTIFIER",
73
+ "VERIFIER_VERSION",
74
+ "Claim",
75
+ "ClaimExtractor",
76
+ "ClaimType",
77
+ "ClaimVerdict",
78
+ "ClaimVerifier",
79
+ "EvidenceMatch",
80
+ "EvidencePassage",
81
+ "ProofReport",
82
+ "ProvenanceEdge",
83
+ "ProvenanceEventEnvelope",
84
+ "ProvenanceExporter",
85
+ "ProvenanceTrace",
86
+ "SourceType",
87
+ "SupportStatus",
88
+ "VerificationPolicy",
89
+ "canonical_json",
90
+ "evidence_content_fingerprint",
91
+ "make_claim_fingerprint",
92
+ "policy_fingerprint",
93
+ "report_fingerprint",
94
+ "run_fingerprint_of",
95
+ ]
@@ -0,0 +1,94 @@
1
+ # Copyright 2026 Daniel Kissel
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """Shared text primitives that must byte-match Swift's semantics.
5
+
6
+ Every helper here exists because a naive Python equivalent demonstrably
7
+ diverges from the Swift reference (verified by differential probes):
8
+
9
+ - ``swift_lower``: Python ``str.lower()`` applies the Unicode Final_Sigma
10
+ contextual rule (``"ΑΣ".lower() == "ας"``); Swift ``lowercased()`` maps
11
+ Σ→σ unconditionally. Fingerprints hash lowercased text, so this must match.
12
+ - ``split_words`` / ``split_letter_runs``: Swift splits on grapheme clusters
13
+ using ``Character.isLetter``/``.isNumber`` (Alphabetic incl. Nl; a cluster
14
+ like e+◌́ is one letter). Python evaluates per code point, so input is
15
+ NFC-normalized first (composing most marks) and Nl is treated as a letter.
16
+ Swift ``Set<String>`` term comparison uses canonical equivalence, which the
17
+ NFC normalization also reproduces.
18
+ - ``swift_trim_whitespace``: Python ``str.strip()`` strips the information
19
+ separators U+001C–U+001F (``isspace() == True``); Swift's
20
+ ``CharacterSet.whitespacesAndNewlines`` does not.
21
+ """
22
+
23
+ from __future__ import annotations
24
+
25
+ import unicodedata
26
+ from typing import List
27
+
28
+
29
+ def swift_lower(text: str) -> str:
30
+ """``String.lowercased()`` parity: unconditional mappings, no Final_Sigma."""
31
+ return text.replace("Σ", "σ").lower()
32
+
33
+
34
+ def _is_letter(ch: str) -> bool:
35
+ # Swift Character.isLetter is the Unicode Alphabetic property, which
36
+ # includes Letter_Number (Nl) characters like Ⅻ.
37
+ return ch.isalpha() or unicodedata.category(ch) == "Nl"
38
+
39
+
40
+ def _is_word_char(ch: str) -> bool:
41
+ return _is_letter(ch) or ch.isnumeric()
42
+
43
+
44
+ def split_words(text: str) -> List[str]:
45
+ """Runs of letter/number characters — Swift's
46
+ ``split(whereSeparator: { !$0.isLetter && !$0.isNumber })`` semantics.
47
+ NFC-normalizes first so combining sequences behave like Swift's grapheme
48
+ clusters and the resulting tokens compare canonically."""
49
+ return _runs(unicodedata.normalize("NFC", text), _is_word_char)
50
+
51
+
52
+ def split_letter_runs(text: str) -> List[str]:
53
+ """Runs of letters only (Swift's ``!$0.isLetter`` separator)."""
54
+ return _runs(unicodedata.normalize("NFC", text), _is_letter)
55
+
56
+
57
+ def _runs(text: str, predicate) -> List[str]:
58
+ words: List[str] = []
59
+ current: List[str] = []
60
+ for ch in text:
61
+ if predicate(ch):
62
+ current.append(ch)
63
+ elif current:
64
+ words.append("".join(current))
65
+ current = []
66
+ if current:
67
+ words.append("".join(current))
68
+ return words
69
+
70
+
71
+ # CharacterSet.whitespacesAndNewlines: Zs + Zl + Zp categories plus the
72
+ # control-range \t \n \v \f \r and U+0085. NOT U+001C-U+001F.
73
+ _TRIM_EXTRA = {"\t", "\n", "\x0b", "\x0c", "\r", "\x85"}
74
+
75
+
76
+ def _is_swift_whitespace(ch: str) -> bool:
77
+ return ch in _TRIM_EXTRA or unicodedata.category(ch) in ("Zs", "Zl", "Zp")
78
+
79
+
80
+ def swift_trim_whitespace(text: str) -> str:
81
+ """``trimmingCharacters(in: .whitespacesAndNewlines)`` parity."""
82
+ start = 0
83
+ end = len(text)
84
+ while start < end and _is_swift_whitespace(text[start]):
85
+ start += 1
86
+ while end > start and _is_swift_whitespace(text[end - 1]):
87
+ end -= 1
88
+ return text[start:end]
89
+
90
+
91
+ def canonical_compare_key(text: str) -> str:
92
+ """Approximation of Swift ``String`` ordering/equality: canonical (NFC)
93
+ normalization before code-point comparison."""
94
+ return unicodedata.normalize("NFC", text)