Publish exact v1.1.4 mirror inventory
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- .zenodo.json +0 -39
- CHANGELOG.md +0 -39
- CITATION.cff +0 -18
- DATA_DICTIONARY.md +0 -41
- LICENSE.md +0 -395
- METHODOLOGY.md +0 -50
- README.md +7 -10
- RELEASE-MANIFEST.json +0 -61
- SECURITY.md +0 -44
- checksums.txt +0 -47
- codemeta.json +0 -39
- distribution/huggingface/README.md +0 -90
- distribution/kaggle/README.md +0 -34
- distribution/kaggle/dataset-metadata.json +0 -42
- examples/payment-statement-audit-example.json +0 -26
- lifted-payments-statement-audit-model-v1.1.3.zip +0 -0
- lifted-payments-statement-audit-model-v1.1.4.zip +3 -0
- llms.txt +0 -26
- payment-statement-audit-template.csv +0 -2
- release-archive.sha256 +1 -1
- requirements-validation.txt +0 -5
- schema/payment-statement-audit.schema.json +0 -155
- test-vectors/invalid/activity-mismatch.json +0 -3
- test-vectors/invalid/duplicate-category.json +0 -3
- test-vectors/invalid/fee-sum-mismatch.json +0 -3
- test-vectors/invalid/fractional-cent.json +0 -3
- test-vectors/invalid/invalid-date.json +0 -3
- test-vectors/invalid/net-fee-mismatch.json +0 -3
- test-vectors/invalid/overlong-period.json +0 -3
- test-vectors/invalid/overprecise-rate.json +0 -3
- test-vectors/invalid/pathological-number.json +0 -4
- test-vectors/invalid/reversed-period.json +0 -3
- test-vectors/invalid/security-data-in-note.json +0 -3
- test-vectors/invalid/unknown-field.json +0 -3
- test-vectors/invalid/wrong-average-ticket.json +0 -3
- test-vectors/invalid/wrong-effective-rate.json +0 -3
- test-vectors/manifest.json +0 -22
- test-vectors/valid/standard-month.json +0 -23
- test-vectors/valid/zero-activity-month.json +0 -16
- tests/__pycache__/test_audit_validator.cpython-312.pyc +0 -0
- tests/__pycache__/test_public_release_attestation.cpython-312.pyc +0 -0
- tests/__pycache__/test_publication_gate.cpython-312.pyc +0 -0
- tests/__pycache__/test_release_assets.cpython-312.pyc +0 -0
- tests/__pycache__/test_release_provenance.cpython-312.pyc +0 -0
- tests/test_audit_validator.py +0 -449
- tests/test_public_release_attestation.py +0 -329
- tests/test_publication_gate.py +0 -574
- tests/test_release_assets.py +0 -275
- tests/test_release_provenance.py +0 -189
.gitattributes
CHANGED
|
@@ -7,3 +7,4 @@
|
|
| 7 |
*.txt text eol=lf
|
| 8 |
*.yaml text eol=lf
|
| 9 |
*.yml text eol=lf
|
|
|
|
|
|
| 7 |
*.txt text eol=lf
|
| 8 |
*.yaml text eol=lf
|
| 9 |
*.yml text eol=lf
|
| 10 |
+
lifted-payments-statement-audit-model-v1.1.4.zip filter=lfs diff=lfs merge=lfs -text
|
.zenodo.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"title": "Lifted Payments Payment Statement Audit Model",
|
| 3 |
-
"upload_type": "dataset",
|
| 4 |
-
"description": "<p>A processor-neutral, machine-readable model for normalizing monthly merchant payment-processing statements without storing cardholder data. Version 1.1.3 preserves the schema 1.1.0 contract and v1.1.2 validator rules while adding clean committed-tree provenance, authoritative remote-tag and monotonic-version checks, pre-execution static gates, and bounded non-executing attestation of GitHub, Zenodo, DOI, Hugging Face, and Software Heritage identities and bytes.</p>",
|
| 5 |
-
"creators": [
|
| 6 |
-
{
|
| 7 |
-
"name": "Lifted Payments",
|
| 8 |
-
"affiliation": "Lifted Holdings"
|
| 9 |
-
}
|
| 10 |
-
],
|
| 11 |
-
"version": "1.1.3",
|
| 12 |
-
"publication_date": "2026-08-02",
|
| 13 |
-
"access_right": "open",
|
| 14 |
-
"license": "cc-by-4.0",
|
| 15 |
-
"language": "eng",
|
| 16 |
-
"keywords": [
|
| 17 |
-
"payment processing",
|
| 18 |
-
"merchant services",
|
| 19 |
-
"effective rate",
|
| 20 |
-
"statement audit",
|
| 21 |
-
"fintech",
|
| 22 |
-
"JSON Schema",
|
| 23 |
-
"payments data",
|
| 24 |
-
"cost analysis"
|
| 25 |
-
],
|
| 26 |
-
"related_identifiers": [
|
| 27 |
-
{
|
| 28 |
-
"identifier": "https://liftedpayments.com/payment-processing-statement-audit/",
|
| 29 |
-
"relation": "isDocumentedBy",
|
| 30 |
-
"resource_type": "publication-technicalnote"
|
| 31 |
-
},
|
| 32 |
-
{
|
| 33 |
-
"identifier": "https://github.com/Lifted-Holdings/payment-processing-resources/releases/tag/v1.1.3",
|
| 34 |
-
"relation": "isSourceOf",
|
| 35 |
-
"resource_type": "software"
|
| 36 |
-
}
|
| 37 |
-
],
|
| 38 |
-
"notes": "All figures and validation vectors are synthetic and do not describe a real merchant. The model contains no cardholder data. The validation report records 2 accepted valid vectors and 14 correctly rejected invalid vectors. Package 1.1.3 preserves the schema 1.1.0 record contract. The publication gate proves declared package and release provenance; it is not an accounting opinion, legal review, interchange-pricing guarantee, or malware sandbox."
|
| 39 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHANGELOG.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
# Changelog
|
| 2 |
-
|
| 3 |
-
All notable changes to the versioned dataset package are recorded here. Published release artifacts remain immutable.
|
| 4 |
-
|
| 5 |
-
## 1.1.3 - 2026-08-02
|
| 6 |
-
|
| 7 |
-
- Split portable package validation from publication readiness so a tagless archive can never claim release provenance.
|
| 8 |
-
- Require a clean committed tree, authoritative origin, complete remote tag inventory, exact local/remote tag alignment, and monotonic new versions.
|
| 9 |
-
- Run static inventory, path, size, encoding, checksum, credential-signature, identity, and provenance checks before executing candidate Python.
|
| 10 |
-
- Add a bounded non-executing public attestor for GitHub release assets, Zenodo metadata and bytes, DOI resolution, Hugging Face archive equality, and Software Heritage branch/tag provenance.
|
| 11 |
-
- Reject unsafe redirects, oversized responses, archive traversal, case-fold aliases, symlinks, undeclared members, digest mismatches, and public identity drift.
|
| 12 |
-
- Add 20 provenance and external-attestation regressions while preserving the schema 1.1.0 record contract.
|
| 13 |
-
|
| 14 |
-
## 1.1.2 - 2026-08-02
|
| 15 |
-
|
| 16 |
-
- Require the publication gate to compare the manifest with the complete candidate release tree.
|
| 17 |
-
- Run the candidate validator's behavioral regression suite in addition to the compact synthetic corpus.
|
| 18 |
-
- Bound release file count, individual asset size, and aggregate release size before content scanning.
|
| 19 |
-
- Reject spreadsheet-formula prefixes in CSV cells without echoing submitted values.
|
| 20 |
-
- Validate trusted title, semantic versions, release date, DOI pair, license, canonical URL, and source-release identity.
|
| 21 |
-
- Block changed files from masquerading as an existing immutable Git tag.
|
| 22 |
-
- Add regression coverage for identity, bank, credential, rounding-tie, and zero-fee edge cases.
|
| 23 |
-
|
| 24 |
-
## 1.1.1 - 2026-08-02
|
| 25 |
-
|
| 26 |
-
Security and release-engineering patch; the record contract remains schema version 1.1.0.
|
| 27 |
-
|
| 28 |
-
- Reject pathological JSON number magnitudes and exponents before Decimal arithmetic.
|
| 29 |
-
- Return stable, value-free errors for unreadable inputs and hostile direct numeric values.
|
| 30 |
-
- Execute the candidate release's own corpus validator in a bounded child process.
|
| 31 |
-
- Block malformed manifests, path traversal, missing critical assets, stale reports, and candidate-validator failures.
|
| 32 |
-
- Scan every declared release asset for common credential signatures.
|
| 33 |
-
- Add an adversarial extreme-number vector and public security/threat-model documentation.
|
| 34 |
-
|
| 35 |
-
## 1.1.0 - 2026-08-02
|
| 36 |
-
|
| 37 |
-
- Defined gross settled purchase volume and net processing fees as the calculation basis.
|
| 38 |
-
- Added exact fee-group, credit, effective-rate, and average-ticket reconciliation.
|
| 39 |
-
- Added the semantic validator, adversarial corpus, pinned runtime, checksums, and fail-closed publication gate.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CITATION.cff
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
cff-version: 1.2.0
|
| 2 |
-
message: "If you use this audit model, cite it using the metadata below."
|
| 3 |
-
title: "Lifted Payments Payment Statement Audit Model"
|
| 4 |
-
type: dataset
|
| 5 |
-
authors:
|
| 6 |
-
- name: "Lifted Payments"
|
| 7 |
-
version: 1.1.3
|
| 8 |
-
date-released: 2026-08-02
|
| 9 |
-
doi: "10.5281/zenodo.21764642"
|
| 10 |
-
url: "https://liftedpayments.com/payment-processing-statement-audit/"
|
| 11 |
-
repository-code: "https://github.com/Lifted-Holdings/payment-processing-resources"
|
| 12 |
-
license: CC-BY-4.0
|
| 13 |
-
keywords:
|
| 14 |
-
- payment processing
|
| 15 |
-
- merchant services
|
| 16 |
-
- effective rate
|
| 17 |
-
- statement audit
|
| 18 |
-
- fintech
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DATA_DICTIONARY.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
| 1 |
-
# Payment statement audit data dictionary
|
| 2 |
-
|
| 3 |
-
This dictionary defines v1.1.0 of the Lifted Payments Payment Statement Audit Model. Words such as “volume,” “fees,” and “transactions” are ambiguous across provider statements; the definitions below are part of the contract, not suggestions.
|
| 4 |
-
|
| 5 |
-
## Record-level fields
|
| 6 |
-
|
| 7 |
-
| Field | Type | Required | Definition |
|
| 8 |
-
|---|---:|:---:|---|
|
| 9 |
-
| `schema_version` | string | yes | Literal `1.1.0`. A different value requires a different schema and validator. |
|
| 10 |
-
| `calculation_basis` | string | yes | Literal `gross_settled_purchase_volume_and_net_processing_fees`. It prevents unlike numerator and denominator conventions from being compared silently. |
|
| 11 |
-
| `statement_period.start` | ISO date | yes | First calendar date represented by the statement, inclusive. |
|
| 12 |
-
| `statement_period.end` | ISO date | yes | Last calendar date represented by the statement, inclusive. It must be on or after `start`; the inclusive period may not exceed 62 days. |
|
| 13 |
-
| `currency` | string | yes | Literal `USD`. Do not convert or combine other currencies in a v1.1.0 record. |
|
| 14 |
-
| `card_volume` | USD | yes | Gross dollar amount of settled purchase transactions in the period. Include the full settled purchase amount, including tax and tip when those are part of the capture. Exclude declines, authorization-only events, voids, refunds, chargebacks, cash advances, reserves, and funding adjustments. |
|
| 15 |
-
| `transaction_count` | integer | yes | Number of settled purchase transactions included in `card_volume`. Exclude declines, authorization-only events, voids, refunds, and chargebacks. Volume and count must both be zero or both be positive. |
|
| 16 |
-
| `gross_processing_fees` | USD | yes | Sum of the nine `fee_groups` before processing-fee credits. It includes only fees for accepting, authorizing, settling, supporting, or administering card processing. |
|
| 17 |
-
| `statement_credits` | USD | yes | Processing-fee credits or rebates applied on the statement. Exclude customer refunds, chargeback principal, reserve releases, deposit adjustments, and other movement of merchant funds. |
|
| 18 |
-
| `total_processing_fees` | USD | yes | Net fee numerator: `gross_processing_fees - statement_credits`. It cannot be negative in v1.1.0. |
|
| 19 |
-
| `effective_rate` | decimal or null | yes | `total_processing_fees / card_volume`, rounded half up to six decimal places. Store `2.2918%` as `0.022918`. It must be `null` when `card_volume` is zero. |
|
| 20 |
-
| `average_ticket` | USD or null | yes | `card_volume / transaction_count`, rounded half up to cents. It must be `null` when `transaction_count` is zero. |
|
| 21 |
-
| `pricing_model` | enum | yes | How pricing is presented on the source statement: `interchange_plus`, `flat_rate`, `tiered`, `subscription`, `dual_pricing`, or `unknown`. This is not an interchange-qualification opinion. |
|
| 22 |
-
| `fee_groups` | array | yes | One entry per used category. Categories are unique, amounts are gross nonnegative charges, and their exact cent sum equals `gross_processing_fees`. For a zero-activity, zero-fee statement, use one `other` entry with amount `0.00` because schema v1.1.0 requires at least one group. |
|
| 23 |
-
| `review_notes` | string array | no | Short explanations of classification decisions. Never put merchant identity, card/account data, credentials, or secrets here. |
|
| 24 |
-
|
| 25 |
-
All USD fields permit at most two decimal places. Rates permit at most six decimal places. Numbers must be finite. The validator imposes high operational ceilings to reject account-number-shaped or clearly implausible input; those ceilings are data-safety bounds, not merchant eligibility limits.
|
| 26 |
-
|
| 27 |
-
## Fee-group taxonomy
|
| 28 |
-
|
| 29 |
-
| Category | Include | Exclude or redirect |
|
| 30 |
-
|---|---|---|
|
| 31 |
-
| `interchange` | Issuer/interchange charges presented by the statement | Network assessments and provider markup |
|
| 32 |
-
| `assessments` | Card-network assessment, access, and brand charges | Interchange and processor markup |
|
| 33 |
-
| `processor_markup` | Provider percentage, basis-point, per-item, or service markup not assigned elsewhere | Pass-through interchange and assessments |
|
| 34 |
-
| `authorization` | Authorization, gateway, capture, AVS, and similar per-attempt service fees | Settled-item markup already classified in `processor_markup` |
|
| 35 |
-
| `monthly` | Monthly account, statement, minimum, batch, or platform administration fees | Equipment service and PCI program fees when separately stated |
|
| 36 |
-
| `pci` | PCI program, non-validation, or compliance-service fees | Penalties unrelated to processing, which belong in `other` with a note |
|
| 37 |
-
| `equipment` | Terminal rental, device service, replacement plan, or connectivity fees charged on the processing statement | Equipment sale principal, financing, or lease obligations outside processing cost |
|
| 38 |
-
| `chargebacks` | Chargeback, retrieval, arbitration, and dispute administration fees | Chargeback transaction principal or lost sale amount |
|
| 39 |
-
| `other` | A processing-related fee that fits no category, with a concise classification note | Refund principal, reserves, taxes withheld, loans/advances, financing principal, or merchant deposits |
|
| 40 |
-
|
| 41 |
-
Never omit a fee to make a rate look better. If the source statement does not provide enough information to classify a processing-related charge, put it in `other` and document the reason. If the statement mixes periods or currencies and they cannot be separated faithfully, do not publish a v1.1.0 record.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LICENSE.md
DELETED
|
@@ -1,395 +0,0 @@
|
|
| 1 |
-
Attribution 4.0 International
|
| 2 |
-
|
| 3 |
-
=======================================================================
|
| 4 |
-
|
| 5 |
-
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
| 6 |
-
does not provide legal services or legal advice. Distribution of
|
| 7 |
-
Creative Commons public licenses does not create a lawyer-client or
|
| 8 |
-
other relationship. Creative Commons makes its licenses and related
|
| 9 |
-
information available on an "as-is" basis. Creative Commons gives no
|
| 10 |
-
warranties regarding its licenses, any material licensed under their
|
| 11 |
-
terms and conditions, or any related information. Creative Commons
|
| 12 |
-
disclaims all liability for damages resulting from their use to the
|
| 13 |
-
fullest extent possible.
|
| 14 |
-
|
| 15 |
-
Using Creative Commons Public Licenses
|
| 16 |
-
|
| 17 |
-
Creative Commons public licenses provide a standard set of terms and
|
| 18 |
-
conditions that creators and other rights holders may use to share
|
| 19 |
-
original works of authorship and other material subject to copyright
|
| 20 |
-
and certain other rights specified in the public license below. The
|
| 21 |
-
following considerations are for informational purposes only, are not
|
| 22 |
-
exhaustive, and do not form part of our licenses.
|
| 23 |
-
|
| 24 |
-
Considerations for licensors: Our public licenses are
|
| 25 |
-
intended for use by those authorized to give the public
|
| 26 |
-
permission to use material in ways otherwise restricted by
|
| 27 |
-
copyright and certain other rights. Our licenses are
|
| 28 |
-
irrevocable. Licensors should read and understand the terms
|
| 29 |
-
and conditions of the license they choose before applying it.
|
| 30 |
-
Licensors should also secure all rights necessary before
|
| 31 |
-
applying our licenses so that the public can reuse the
|
| 32 |
-
material as expected. Licensors should clearly mark any
|
| 33 |
-
material not subject to the license. This includes other CC-
|
| 34 |
-
licensed material, or material used under an exception or
|
| 35 |
-
limitation to copyright. More considerations for licensors:
|
| 36 |
-
wiki.creativecommons.org/Considerations_for_licensors
|
| 37 |
-
|
| 38 |
-
Considerations for the public: By using one of our public
|
| 39 |
-
licenses, a licensor grants the public permission to use the
|
| 40 |
-
licensed material under specified terms and conditions. If
|
| 41 |
-
the licensor's permission is not necessary for any reason--for
|
| 42 |
-
example, because of any applicable exception or limitation to
|
| 43 |
-
copyright--then that use is not regulated by the license. Our
|
| 44 |
-
licenses grant only permissions under copyright and certain
|
| 45 |
-
other rights that a licensor has authority to grant. Use of
|
| 46 |
-
the licensed material may still be restricted for other
|
| 47 |
-
reasons, including because others have copyright or other
|
| 48 |
-
rights in the material. A licensor may make special requests,
|
| 49 |
-
such as asking that all changes be marked or described.
|
| 50 |
-
Although not required by our licenses, you are encouraged to
|
| 51 |
-
respect those requests where reasonable. More considerations
|
| 52 |
-
for the public:
|
| 53 |
-
wiki.creativecommons.org/Considerations_for_licensees
|
| 54 |
-
|
| 55 |
-
=======================================================================
|
| 56 |
-
|
| 57 |
-
Creative Commons Attribution 4.0 International Public License
|
| 58 |
-
|
| 59 |
-
By exercising the Licensed Rights (defined below), You accept and agree
|
| 60 |
-
to be bound by the terms and conditions of this Creative Commons
|
| 61 |
-
Attribution 4.0 International Public License ("Public License"). To the
|
| 62 |
-
extent this Public License may be interpreted as a contract, You are
|
| 63 |
-
granted the Licensed Rights in consideration of Your acceptance of
|
| 64 |
-
these terms and conditions, and the Licensor grants You such rights in
|
| 65 |
-
consideration of benefits the Licensor receives from making the
|
| 66 |
-
Licensed Material available under these terms and conditions.
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
Section 1 -- Definitions.
|
| 70 |
-
|
| 71 |
-
a. Adapted Material means material subject to Copyright and Similar
|
| 72 |
-
Rights that is derived from or based upon the Licensed Material
|
| 73 |
-
and in which the Licensed Material is translated, altered,
|
| 74 |
-
arranged, transformed, or otherwise modified in a manner requiring
|
| 75 |
-
permission under the Copyright and Similar Rights held by the
|
| 76 |
-
Licensor. For purposes of this Public License, where the Licensed
|
| 77 |
-
Material is a musical work, performance, or sound recording,
|
| 78 |
-
Adapted Material is always produced where the Licensed Material is
|
| 79 |
-
synched in timed relation with a moving image.
|
| 80 |
-
|
| 81 |
-
b. Adapter's License means the license You apply to Your Copyright
|
| 82 |
-
and Similar Rights in Your contributions to Adapted Material in
|
| 83 |
-
accordance with the terms and conditions of this Public License.
|
| 84 |
-
|
| 85 |
-
c. Copyright and Similar Rights means copyright and/or similar rights
|
| 86 |
-
closely related to copyright including, without limitation,
|
| 87 |
-
performance, broadcast, sound recording, and Sui Generis Database
|
| 88 |
-
Rights, without regard to how the rights are labeled or
|
| 89 |
-
categorized. For purposes of this Public License, the rights
|
| 90 |
-
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
| 91 |
-
Rights.
|
| 92 |
-
|
| 93 |
-
d. Effective Technological Measures means those measures that, in the
|
| 94 |
-
absence of proper authority, may not be circumvented under laws
|
| 95 |
-
fulfilling obligations under Article 11 of the WIPO Copyright
|
| 96 |
-
Treaty adopted on December 20, 1996, and/or similar international
|
| 97 |
-
agreements.
|
| 98 |
-
|
| 99 |
-
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
| 100 |
-
any other exception or limitation to Copyright and Similar Rights
|
| 101 |
-
that applies to Your use of the Licensed Material.
|
| 102 |
-
|
| 103 |
-
f. Licensed Material means the artistic or literary work, database,
|
| 104 |
-
or other material to which the Licensor applied this Public
|
| 105 |
-
License.
|
| 106 |
-
|
| 107 |
-
g. Licensed Rights means the rights granted to You subject to the
|
| 108 |
-
terms and conditions of this Public License, which are limited to
|
| 109 |
-
all Copyright and Similar Rights that apply to Your use of the
|
| 110 |
-
Licensed Material and that the Licensor has authority to license.
|
| 111 |
-
|
| 112 |
-
h. Licensor means the individual(s) or entity(ies) granting rights
|
| 113 |
-
under this Public License.
|
| 114 |
-
|
| 115 |
-
i. Share means to provide material to the public by any means or
|
| 116 |
-
process that requires permission under the Licensed Rights, such
|
| 117 |
-
as reproduction, public display, public performance, distribution,
|
| 118 |
-
dissemination, communication, or importation, and to make material
|
| 119 |
-
available to the public including in ways that members of the
|
| 120 |
-
public may access the material from a place and at a time
|
| 121 |
-
individually chosen by them.
|
| 122 |
-
|
| 123 |
-
j. Sui Generis Database Rights means rights other than copyright
|
| 124 |
-
resulting from Directive 96/9/EC of the European Parliament and of
|
| 125 |
-
the Council of 11 March 1996 on the legal protection of databases,
|
| 126 |
-
as amended and/or succeeded, as well as other essentially
|
| 127 |
-
equivalent rights anywhere in the world.
|
| 128 |
-
|
| 129 |
-
k. You means the individual or entity exercising the Licensed Rights
|
| 130 |
-
under this Public License. Your has a corresponding meaning.
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
Section 2 -- Scope.
|
| 134 |
-
|
| 135 |
-
a. License grant.
|
| 136 |
-
|
| 137 |
-
1. Subject to the terms and conditions of this Public License,
|
| 138 |
-
the Licensor hereby grants You a worldwide, royalty-free,
|
| 139 |
-
non-sublicensable, non-exclusive, irrevocable license to
|
| 140 |
-
exercise the Licensed Rights in the Licensed Material to:
|
| 141 |
-
|
| 142 |
-
a. reproduce and Share the Licensed Material, in whole or
|
| 143 |
-
in part; and
|
| 144 |
-
|
| 145 |
-
b. produce, reproduce, and Share Adapted Material.
|
| 146 |
-
|
| 147 |
-
2. Exceptions and Limitations. For the avoidance of doubt, where
|
| 148 |
-
Exceptions and Limitations apply to Your use, this Public
|
| 149 |
-
License does not apply, and You do not need to comply with
|
| 150 |
-
its terms and conditions.
|
| 151 |
-
|
| 152 |
-
3. Term. The term of this Public License is specified in Section
|
| 153 |
-
6(a).
|
| 154 |
-
|
| 155 |
-
4. Media and formats; technical modifications allowed. The
|
| 156 |
-
Licensor authorizes You to exercise the Licensed Rights in
|
| 157 |
-
all media and formats whether now known or hereafter created,
|
| 158 |
-
and to make technical modifications necessary to do so. The
|
| 159 |
-
Licensor waives and/or agrees not to assert any right or
|
| 160 |
-
authority to forbid You from making technical modifications
|
| 161 |
-
necessary to exercise the Licensed Rights, including
|
| 162 |
-
technical modifications necessary to circumvent Effective
|
| 163 |
-
Technological Measures. For purposes of this Public License,
|
| 164 |
-
simply making modifications authorized by this Section 2(a)
|
| 165 |
-
(4) never produces Adapted Material.
|
| 166 |
-
|
| 167 |
-
5. Downstream recipients.
|
| 168 |
-
|
| 169 |
-
a. Offer from the Licensor -- Licensed Material. Every
|
| 170 |
-
recipient of the Licensed Material automatically
|
| 171 |
-
receives an offer from the Licensor to exercise the
|
| 172 |
-
Licensed Rights under the terms and conditions of this
|
| 173 |
-
Public License.
|
| 174 |
-
|
| 175 |
-
b. No downstream restrictions. You may not offer or impose
|
| 176 |
-
any additional or different terms or conditions on, or
|
| 177 |
-
apply any Effective Technological Measures to, the
|
| 178 |
-
Licensed Material if doing so restricts exercise of the
|
| 179 |
-
Licensed Rights by any recipient of the Licensed
|
| 180 |
-
Material.
|
| 181 |
-
|
| 182 |
-
6. No endorsement. Nothing in this Public License constitutes or
|
| 183 |
-
may be construed as permission to assert or imply that You
|
| 184 |
-
are, or that Your use of the Licensed Material is, connected
|
| 185 |
-
with, or sponsored, endorsed, or granted official status by,
|
| 186 |
-
the Licensor or others designated to receive attribution as
|
| 187 |
-
provided in Section 3(a)(1)(A)(i).
|
| 188 |
-
|
| 189 |
-
b. Other rights.
|
| 190 |
-
|
| 191 |
-
1. Moral rights, such as the right of integrity, are not
|
| 192 |
-
licensed under this Public License, nor are publicity,
|
| 193 |
-
privacy, and/or other similar personality rights; however, to
|
| 194 |
-
the extent possible, the Licensor waives and/or agrees not to
|
| 195 |
-
assert any such rights held by the Licensor to the limited
|
| 196 |
-
extent necessary to allow You to exercise the Licensed
|
| 197 |
-
Rights, but not otherwise.
|
| 198 |
-
|
| 199 |
-
2. Patent and trademark rights are not licensed under this
|
| 200 |
-
Public License.
|
| 201 |
-
|
| 202 |
-
3. To the extent possible, the Licensor waives any right to
|
| 203 |
-
collect royalties from You for the exercise of the Licensed
|
| 204 |
-
Rights, whether directly or through a collecting society
|
| 205 |
-
under any voluntary or waivable statutory or compulsory
|
| 206 |
-
licensing scheme. In all other cases the Licensor expressly
|
| 207 |
-
reserves any right to collect such royalties.
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
Section 3 -- License Conditions.
|
| 211 |
-
|
| 212 |
-
Your exercise of the Licensed Rights is expressly made subject to the
|
| 213 |
-
following conditions.
|
| 214 |
-
|
| 215 |
-
a. Attribution.
|
| 216 |
-
|
| 217 |
-
1. If You Share the Licensed Material (including in modified
|
| 218 |
-
form), You must:
|
| 219 |
-
|
| 220 |
-
a. retain the following if it is supplied by the Licensor
|
| 221 |
-
with the Licensed Material:
|
| 222 |
-
|
| 223 |
-
i. identification of the creator(s) of the Licensed
|
| 224 |
-
Material and any others designated to receive
|
| 225 |
-
attribution, in any reasonable manner requested by
|
| 226 |
-
the Licensor (including by pseudonym if
|
| 227 |
-
designated);
|
| 228 |
-
|
| 229 |
-
ii. a copyright notice;
|
| 230 |
-
|
| 231 |
-
iii. a notice that refers to this Public License;
|
| 232 |
-
|
| 233 |
-
iv. a notice that refers to the disclaimer of
|
| 234 |
-
warranties;
|
| 235 |
-
|
| 236 |
-
v. a URI or hyperlink to the Licensed Material to the
|
| 237 |
-
extent reasonably practicable;
|
| 238 |
-
|
| 239 |
-
b. indicate if You modified the Licensed Material and
|
| 240 |
-
retain an indication of any previous modifications; and
|
| 241 |
-
|
| 242 |
-
c. indicate the Licensed Material is licensed under this
|
| 243 |
-
Public License, and include the text of, or the URI or
|
| 244 |
-
hyperlink to, this Public License.
|
| 245 |
-
|
| 246 |
-
2. You may satisfy the conditions in Section 3(a)(1) in any
|
| 247 |
-
reasonable manner based on the medium, means, and context in
|
| 248 |
-
which You Share the Licensed Material. For example, it may be
|
| 249 |
-
reasonable to satisfy the conditions by providing a URI or
|
| 250 |
-
hyperlink to a resource that includes the required
|
| 251 |
-
information.
|
| 252 |
-
|
| 253 |
-
3. If requested by the Licensor, You must remove any of the
|
| 254 |
-
information required by Section 3(a)(1)(A) to the extent
|
| 255 |
-
reasonably practicable.
|
| 256 |
-
|
| 257 |
-
4. If You Share Adapted Material You produce, the Adapter's
|
| 258 |
-
License You apply must not prevent recipients of the Adapted
|
| 259 |
-
Material from complying with this Public License.
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
Section 4 -- Sui Generis Database Rights.
|
| 263 |
-
|
| 264 |
-
Where the Licensed Rights include Sui Generis Database Rights that
|
| 265 |
-
apply to Your use of the Licensed Material:
|
| 266 |
-
|
| 267 |
-
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
| 268 |
-
to extract, reuse, reproduce, and Share all or a substantial
|
| 269 |
-
portion of the contents of the database;
|
| 270 |
-
|
| 271 |
-
b. if You include all or a substantial portion of the database
|
| 272 |
-
contents in a database in which You have Sui Generis Database
|
| 273 |
-
Rights, then the database in which You have Sui Generis Database
|
| 274 |
-
Rights (but not its individual contents) is Adapted Material; and
|
| 275 |
-
|
| 276 |
-
c. You must comply with the conditions in Section 3(a) if You Share
|
| 277 |
-
all or a substantial portion of the contents of the database.
|
| 278 |
-
|
| 279 |
-
For the avoidance of doubt, this Section 4 supplements and does not
|
| 280 |
-
replace Your obligations under this Public License where the Licensed
|
| 281 |
-
Rights include other Copyright and Similar Rights.
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
| 285 |
-
|
| 286 |
-
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
| 287 |
-
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
| 288 |
-
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
| 289 |
-
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
| 290 |
-
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
| 291 |
-
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
| 292 |
-
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
| 293 |
-
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
| 294 |
-
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
| 295 |
-
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
| 296 |
-
|
| 297 |
-
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
| 298 |
-
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
| 299 |
-
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
| 300 |
-
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
| 301 |
-
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
| 302 |
-
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
| 303 |
-
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
| 304 |
-
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
| 305 |
-
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
| 306 |
-
|
| 307 |
-
c. The disclaimer of warranties and limitation of liability provided
|
| 308 |
-
above shall be interpreted in a manner that, to the extent
|
| 309 |
-
possible, most closely approximates an absolute disclaimer and
|
| 310 |
-
waiver of all liability.
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
Section 6 -- Term and Termination.
|
| 314 |
-
|
| 315 |
-
a. This Public License applies for the term of the Copyright and
|
| 316 |
-
Similar Rights licensed here. However, if You fail to comply with
|
| 317 |
-
this Public License, then Your rights under this Public License
|
| 318 |
-
terminate automatically.
|
| 319 |
-
|
| 320 |
-
b. Where Your right to use the Licensed Material has terminated under
|
| 321 |
-
Section 6(a), it reinstates:
|
| 322 |
-
|
| 323 |
-
1. automatically as of the date the violation is cured, provided
|
| 324 |
-
it is cured within 30 days of Your discovery of the
|
| 325 |
-
violation; or
|
| 326 |
-
|
| 327 |
-
2. upon express reinstatement by the Licensor.
|
| 328 |
-
|
| 329 |
-
For the avoidance of doubt, this Section 6(b) does not affect any
|
| 330 |
-
right the Licensor may have to seek remedies for Your violations
|
| 331 |
-
of this Public License.
|
| 332 |
-
|
| 333 |
-
c. For the avoidance of doubt, the Licensor may also offer the
|
| 334 |
-
Licensed Material under separate terms or conditions or stop
|
| 335 |
-
distributing the Licensed Material at any time; however, doing so
|
| 336 |
-
will not terminate this Public License.
|
| 337 |
-
|
| 338 |
-
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
| 339 |
-
License.
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
Section 7 -- Other Terms and Conditions.
|
| 343 |
-
|
| 344 |
-
a. The Licensor shall not be bound by any additional or different
|
| 345 |
-
terms or conditions communicated by You unless expressly agreed.
|
| 346 |
-
|
| 347 |
-
b. Any arrangements, understandings, or agreements regarding the
|
| 348 |
-
Licensed Material not stated herein are separate from and
|
| 349 |
-
independent of the terms and conditions of this Public License.
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
Section 8 -- Interpretation.
|
| 353 |
-
|
| 354 |
-
a. For the avoidance of doubt, this Public License does not, and
|
| 355 |
-
shall not be interpreted to, reduce, limit, restrict, or impose
|
| 356 |
-
conditions on any use of the Licensed Material that could lawfully
|
| 357 |
-
be made without permission under this Public License.
|
| 358 |
-
|
| 359 |
-
b. To the extent possible, if any provision of this Public License is
|
| 360 |
-
deemed unenforceable, it shall be automatically reformed to the
|
| 361 |
-
minimum extent necessary to make it enforceable. If the provision
|
| 362 |
-
cannot be reformed, it shall be severed from this Public License
|
| 363 |
-
without affecting the enforceability of the remaining terms and
|
| 364 |
-
conditions.
|
| 365 |
-
|
| 366 |
-
c. No term or condition of this Public License will be waived and no
|
| 367 |
-
failure to comply consented to unless expressly agreed to by the
|
| 368 |
-
Licensor.
|
| 369 |
-
|
| 370 |
-
d. Nothing in this Public License constitutes or may be interpreted
|
| 371 |
-
as a limitation upon, or waiver of, any privileges and immunities
|
| 372 |
-
that apply to the Licensor or You, including from the legal
|
| 373 |
-
processes of any jurisdiction or authority.
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
=======================================================================
|
| 377 |
-
|
| 378 |
-
Creative Commons is not a party to its public licenses.
|
| 379 |
-
Notwithstanding, Creative Commons may elect to apply one of its public
|
| 380 |
-
licenses to material it publishes and in those instances will be
|
| 381 |
-
considered the “Licensor.” The text of the Creative Commons public
|
| 382 |
-
licenses is dedicated to the public domain under the CC0 Public Domain
|
| 383 |
-
Dedication. Except for the limited purpose of indicating that material
|
| 384 |
-
is shared under a Creative Commons public license or as otherwise
|
| 385 |
-
permitted by the Creative Commons policies published at
|
| 386 |
-
creativecommons.org/policies, Creative Commons does not authorize the
|
| 387 |
-
use of the trademark "Creative Commons" or any other trademark or logo
|
| 388 |
-
of Creative Commons without its prior written consent including,
|
| 389 |
-
without limitation, in connection with any unauthorized modifications
|
| 390 |
-
to any of its public licenses or any other arrangements,
|
| 391 |
-
understandings, or agreements concerning use of licensed material. For
|
| 392 |
-
the avoidance of doubt, this paragraph does not form part of the public
|
| 393 |
-
licenses.
|
| 394 |
-
|
| 395 |
-
Creative Commons may be contacted at creativecommons.org.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
METHODOLOGY.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
# Statement audit methodology and limitations
|
| 2 |
-
|
| 3 |
-
## Purpose
|
| 4 |
-
|
| 5 |
-
The Lifted Payments Payment Statement Audit Model normalizes one processing statement into comparable monthly totals. It is designed for reproducible arithmetic, fee-taxonomy review, and month-over-month or provider-to-provider comparison. It is not a substitute for the original statement, merchant agreement, card-brand rules, tax advice, legal advice, an accounting opinion, or an interchange-qualification analysis.
|
| 6 |
-
|
| 7 |
-
## Procedure
|
| 8 |
-
|
| 9 |
-
1. Confirm that the source covers one USD statement period of no more than 62 inclusive days. If the statement combines currencies or inseparable periods, stop.
|
| 10 |
-
2. Record gross settled purchase volume and its matching settled purchase count. Do not use net deposits, net sales after refunds, authorization volume, or funding totals.
|
| 11 |
-
3. Identify every processing-related charge for the same period. Exclude transaction principal, refund and chargeback principal, reserves, withholding, loan or advance repayment, and equipment financing principal.
|
| 12 |
-
4. Assign each gross charge exactly once to the taxonomy in [`DATA_DICTIONARY.md`](./DATA_DICTIONARY.md). Put ambiguous processing charges in `other` with a note; do not drop them.
|
| 13 |
-
5. Sum the fee groups to `gross_processing_fees`. Record only processing-fee rebates or credits in `statement_credits`. Subtract those credits to obtain `total_processing_fees`.
|
| 14 |
-
6. Compute the effective rate from net processing fees and gross settled purchase volume. Compute average ticket from that same volume and count. Use decimal arithmetic and round half up only at the published precision.
|
| 15 |
-
7. Run the companion validator. Correct the source mapping—not the validator result—when a rule fails. Preserve the source statement privately according to the merchant’s controls; never attach it to this public resource.
|
| 16 |
-
|
| 17 |
-
## Equations
|
| 18 |
-
|
| 19 |
-
```text
|
| 20 |
-
gross_processing_fees = exact sum(fee_groups.amount)
|
| 21 |
-
total_processing_fees = gross_processing_fees - statement_credits
|
| 22 |
-
effective_rate = round_half_up(total_processing_fees / card_volume, 6)
|
| 23 |
-
average_ticket = round_half_up(card_volume / transaction_count, 2)
|
| 24 |
-
```
|
| 25 |
-
|
| 26 |
-
When volume and count are zero, `effective_rate` and `average_ticket` are `null`. Fixed monthly fees may still make `total_processing_fees` positive. A percentage shown to people is `effective_rate × 100`; the JSON value remains a decimal.
|
| 27 |
-
|
| 28 |
-
If a zero-activity statement also has zero processing fees, retain one explicit `other` fee group with amount `0.00`; schema v1.1.0 requires one fee-group entry and this convention avoids inventing a positive charge. CSV text cells beginning with `=`, `+`, `-`, or `@` (after leading whitespace) are rejected because spreadsheet software may interpret them as formulas.
|
| 29 |
-
|
| 30 |
-
## What the effective rate can and cannot show
|
| 31 |
-
|
| 32 |
-
The rate is an all-in normalization of the included statement costs. It can support consistent comparisons when records use the same basis. It does not isolate provider margin, prove that interchange was qualified correctly, predict a future bill, or guarantee savings. Card mix, ticket size, acceptance channel, rewards mix, disputes, seasonality, statement timing, and fee changes can move the rate without a pricing change.
|
| 33 |
-
|
| 34 |
-
Comparisons should use multiple representative statements when available and should present absolute dollars, volume, transaction count, fee groups, and rate together. A single rate without its basis and period is not a complete audit.
|
| 35 |
-
|
| 36 |
-
## Validation architecture
|
| 37 |
-
|
| 38 |
-
The JSON Schema enforces types, required fields, enums, bounds, and unknown-field rejection. The Python validator additionally enables date-format assertion, parses JSON numbers as `Decimal`, rejects duplicate keys and non-finite values, and enforces cross-field accounting rules. This split is intentional: Draft 2020-12 `format` is annotation by default, and JSON Schema does not express date ordering or arithmetic equality across fields.
|
| 39 |
-
|
| 40 |
-
Validation errors expose only rule code, JSON Pointer path, and a fixed message. They do not echo submitted values. The shipped corpus contains valid and deliberately invalid synthetic vectors so independent users can reproduce both acceptance and rejection behavior.
|
| 41 |
-
|
| 42 |
-
## Privacy and security boundary
|
| 43 |
-
|
| 44 |
-
This model needs statement-level aggregates only. It has no fields for PAN, truncated PAN, cardholder name, expiration date, track data, security codes, PIN/PIN block, bank account or routing numbers, tax or government identifiers, merchant owner data, credentials, tokens, or secrets. Unknown fields are rejected. Notes are scanned for Luhn-valid PAN-like sequences, labeled authentication/bank data, email addresses, and common credential patterns.
|
| 45 |
-
|
| 46 |
-
Automated screening reduces accidental disclosure; it cannot prove that arbitrary prose contains no personal or confidential information. A human must review any record before public release. Never use this repository or a public dataset mirror to upload a real merchant statement or a record containing merchant-identifying information.
|
| 47 |
-
|
| 48 |
-
## Corrections and versioning
|
| 49 |
-
|
| 50 |
-
Published version artifacts and their checksums are immutable. A calculation or contract change receives a new semantic version, GitHub release, and Zenodo version DOI linked by the concept DOI. Metadata-only corrections that do not change released files may be amended at the archive, but the repository documents the correction. Known limitations are disclosed rather than silently “fixed” in prior versions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -9,30 +9,25 @@ tags:
|
|
| 9 |
- payments
|
| 10 |
- merchant-services
|
| 11 |
- effective-rate
|
| 12 |
-
configs:
|
| 13 |
-
- config_name: default
|
| 14 |
-
data_files:
|
| 15 |
-
- split: examples
|
| 16 |
-
path: examples/payment-statement-audit-example.json
|
| 17 |
---
|
| 18 |
|
| 19 |
# Lifted Payments Payment Statement Audit Model
|
| 20 |
|
| 21 |
A processor-neutral data contract for turning monthly merchant payment-processing totals into a consistent, comparable audit record. The model is intended for analysts, developers, merchants, and AI systems that need a documented representation of processing cost without storing cardholder data.
|
| 22 |
|
| 23 |
-
This distribution contains package version **1.1.
|
| 24 |
|
| 25 |
## Persistent identity
|
| 26 |
|
| 27 |
- Canonical methodology: https://liftedpayments.com/payment-processing-statement-audit/
|
| 28 |
-
- Version DOI: https://doi.org/10.5281/zenodo.
|
| 29 |
- Concept DOI: https://doi.org/10.5281/zenodo.21761714
|
| 30 |
-
- Versioned source release: https://github.com/Lifted-Holdings/payment-processing-resources/releases/tag/v1.1.
|
| 31 |
- Source repository: https://github.com/Lifted-Holdings/payment-processing-resources
|
| 32 |
|
| 33 |
## Files
|
| 34 |
|
| 35 |
-
|
|
| 36 |
|---|---|
|
| 37 |
| `payment-statement-audit-template.csv` | Spreadsheet-ready header for one monthly audit record |
|
| 38 |
| `schema/payment-statement-audit.schema.json` | JSON Schema Draft 2020-12 validation contract |
|
|
@@ -44,6 +39,8 @@ This distribution contains package version **1.1.3** and its schema **1.1.0** co
|
|
| 44 |
| `codemeta.json` | Schema.org and CodeMeta dataset identity |
|
| 45 |
| `checksums.txt` | SHA-256 integrity values for the portable data files |
|
| 46 |
|
|
|
|
|
|
|
| 47 |
## Core fields
|
| 48 |
|
| 49 |
| Field | Meaning |
|
|
@@ -83,7 +80,7 @@ The included example is synthetic and describes no real merchant. Never add card
|
|
| 83 |
|
| 84 |
## Citation
|
| 85 |
|
| 86 |
-
> Lifted Payments. (2026). *Lifted Payments Payment Statement Audit Model* (Version 1.1.
|
| 87 |
|
| 88 |
## License
|
| 89 |
|
|
|
|
| 9 |
- payments
|
| 10 |
- merchant-services
|
| 11 |
- effective-rate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
# Lifted Payments Payment Statement Audit Model
|
| 15 |
|
| 16 |
A processor-neutral data contract for turning monthly merchant payment-processing totals into a consistent, comparable audit record. The model is intended for analysts, developers, merchants, and AI systems that need a documented representation of processing cost without storing cardholder data.
|
| 17 |
|
| 18 |
+
This distribution contains package version **1.1.4** and its schema **1.1.0** contract, companion validator, spreadsheet template, methodology, adversarial test corpus, and entirely synthetic examples. It is a reusable specification and demonstration package, not a collection of real merchant statements. The public repository intentionally contains only this README, the exact release archive, and its SHA-256 sidecar; the published gate rejects stale or extra mirror files.
|
| 19 |
|
| 20 |
## Persistent identity
|
| 21 |
|
| 22 |
- Canonical methodology: https://liftedpayments.com/payment-processing-statement-audit/
|
| 23 |
+
- Version DOI: https://doi.org/10.5281/zenodo.21765280
|
| 24 |
- Concept DOI: https://doi.org/10.5281/zenodo.21761714
|
| 25 |
+
- Versioned source release: https://github.com/Lifted-Holdings/payment-processing-resources/releases/tag/v1.1.4
|
| 26 |
- Source repository: https://github.com/Lifted-Holdings/payment-processing-resources
|
| 27 |
|
| 28 |
## Files
|
| 29 |
|
| 30 |
+
| Path inside the release archive | Role |
|
| 31 |
|---|---|
|
| 32 |
| `payment-statement-audit-template.csv` | Spreadsheet-ready header for one monthly audit record |
|
| 33 |
| `schema/payment-statement-audit.schema.json` | JSON Schema Draft 2020-12 validation contract |
|
|
|
|
| 39 |
| `codemeta.json` | Schema.org and CodeMeta dataset identity |
|
| 40 |
| `checksums.txt` | SHA-256 integrity values for the portable data files |
|
| 41 |
|
| 42 |
+
The mirror-level `release-archive.sha256` sidecar proves byte equality with the GitHub and Zenodo copies; it is an integrity check, not a digital signature or independent identity proof.
|
| 43 |
+
|
| 44 |
## Core fields
|
| 45 |
|
| 46 |
| Field | Meaning |
|
|
|
|
| 80 |
|
| 81 |
## Citation
|
| 82 |
|
| 83 |
+
> Lifted Payments. (2026). *Lifted Payments Payment Statement Audit Model* (Version 1.1.4). Zenodo. https://doi.org/10.5281/zenodo.21765280
|
| 84 |
|
| 85 |
## License
|
| 86 |
|
RELEASE-MANIFEST.json
DELETED
|
@@ -1,61 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"title": "Lifted Payments Payment Statement Audit Model",
|
| 3 |
-
"version": "1.1.3",
|
| 4 |
-
"schema_version": "1.1.0",
|
| 5 |
-
"release_date": "2026-08-02",
|
| 6 |
-
"version_doi": "10.5281/zenodo.21764642",
|
| 7 |
-
"concept_doi": "10.5281/zenodo.21761714",
|
| 8 |
-
"canonical_url": "https://liftedpayments.com/payment-processing-statement-audit/",
|
| 9 |
-
"source_release": "https://github.com/Lifted-Holdings/payment-processing-resources/releases/tag/v1.1.3",
|
| 10 |
-
"license": "CC-BY-4.0",
|
| 11 |
-
"files": [
|
| 12 |
-
".gitattributes",
|
| 13 |
-
".zenodo.json",
|
| 14 |
-
"CHANGELOG.md",
|
| 15 |
-
"CITATION.cff",
|
| 16 |
-
"checksums.txt",
|
| 17 |
-
"codemeta.json",
|
| 18 |
-
"DATA_DICTIONARY.md",
|
| 19 |
-
"distribution/huggingface/README.md",
|
| 20 |
-
"distribution/kaggle/dataset-metadata.json",
|
| 21 |
-
"distribution/kaggle/README.md",
|
| 22 |
-
"examples/payment-statement-audit-example.json",
|
| 23 |
-
"LICENSE.md",
|
| 24 |
-
"llms.txt",
|
| 25 |
-
"METHODOLOGY.md",
|
| 26 |
-
"payment-statement-audit-template.csv",
|
| 27 |
-
"README.md",
|
| 28 |
-
"RELEASE-MANIFEST.json",
|
| 29 |
-
"requirements-validation.txt",
|
| 30 |
-
"schema/payment-statement-audit.schema.json",
|
| 31 |
-
"SECURITY.md",
|
| 32 |
-
"test-vectors/invalid/activity-mismatch.json",
|
| 33 |
-
"test-vectors/invalid/duplicate-category.json",
|
| 34 |
-
"test-vectors/invalid/fee-sum-mismatch.json",
|
| 35 |
-
"test-vectors/invalid/fractional-cent.json",
|
| 36 |
-
"test-vectors/invalid/invalid-date.json",
|
| 37 |
-
"test-vectors/invalid/net-fee-mismatch.json",
|
| 38 |
-
"test-vectors/invalid/overlong-period.json",
|
| 39 |
-
"test-vectors/invalid/overprecise-rate.json",
|
| 40 |
-
"test-vectors/invalid/pathological-number.json",
|
| 41 |
-
"test-vectors/invalid/security-data-in-note.json",
|
| 42 |
-
"test-vectors/invalid/reversed-period.json",
|
| 43 |
-
"test-vectors/invalid/unknown-field.json",
|
| 44 |
-
"test-vectors/invalid/wrong-average-ticket.json",
|
| 45 |
-
"test-vectors/invalid/wrong-effective-rate.json",
|
| 46 |
-
"test-vectors/manifest.json",
|
| 47 |
-
"test-vectors/valid/standard-month.json",
|
| 48 |
-
"test-vectors/valid/zero-activity-month.json",
|
| 49 |
-
"tests/test_audit_validator.py",
|
| 50 |
-
"tests/test_public_release_attestation.py",
|
| 51 |
-
"tests/test_publication_gate.py",
|
| 52 |
-
"tests/test_release_assets.py",
|
| 53 |
-
"tests/test_release_provenance.py",
|
| 54 |
-
"tools/public_release_attestation.py",
|
| 55 |
-
"tools/publication_gate.py",
|
| 56 |
-
"tools/release_provenance.py",
|
| 57 |
-
"tools/update_checksums.py",
|
| 58 |
-
"tools/validate_audit.py",
|
| 59 |
-
"validation-report.json"
|
| 60 |
-
]
|
| 61 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SECURITY.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
# Security policy and publication threat model
|
| 2 |
-
|
| 3 |
-
## Supported release
|
| 4 |
-
|
| 5 |
-
Security fixes are applied to the newest versioned release. Published GitHub and Zenodo artifacts are immutable; a fix receives a new release, checksums, validation report, and Zenodo version DOI.
|
| 6 |
-
|
| 7 |
-
## What the publication gate defends
|
| 8 |
-
|
| 9 |
-
The release gate is designed to fail closed when it encounters:
|
| 10 |
-
|
| 11 |
-
- a malformed, incomplete, duplicated, absolute, or path-traversing manifest;
|
| 12 |
-
- an undeclared file in the candidate release tree;
|
| 13 |
-
- a missing, symlinked, non-UTF-8, or non-LF declared artifact;
|
| 14 |
-
- an excessive file count, individual asset size, or aggregate release size;
|
| 15 |
-
- a checksum mismatch or undeclared security-critical file;
|
| 16 |
-
- a validator that fails, times out, emits malformed output, or does not reproduce the corpus;
|
| 17 |
-
- a candidate validator that fails its bounded behavioral regression suite;
|
| 18 |
-
- an unpinned validation dependency or stale validation report;
|
| 19 |
-
- inconsistent package, schema, citation, DOI, or source-release identity;
|
| 20 |
-
- a candidate that reuses an existing release version while changing its tagged files;
|
| 21 |
-
- a tagless archive or incomplete clone presented as publication-ready;
|
| 22 |
-
- a dirty or uncommitted candidate tree;
|
| 23 |
-
- an origin outside the authoritative Lifted Holdings repository;
|
| 24 |
-
- an unavailable, malformed, missing, divergent, or non-monotonic remote release tag;
|
| 25 |
-
- common private-key, cloud-key, repository-token, model-token, chat-token, or live payment-key signatures anywhere in the declared release; or
|
| 26 |
-
- synthetic records that violate structural, accounting, precision, period, privacy, size, depth, safe-number, or spreadsheet-formula rules.
|
| 27 |
-
|
| 28 |
-
Candidate validation runs in a bounded child process and must return a machine-readable corpus report. Gate output contains fixed rule messages and hashes, never released file contents or submitted statement values.
|
| 29 |
-
|
| 30 |
-
## Assurance modes and execution order
|
| 31 |
-
|
| 32 |
-
`--mode package` is portable and proves internal consistency only. Its successful status is `valid`, never `ready` or `verified`. `--mode candidate` is the publication boundary and requires a real clean Git worktree, committed byte identity, the authoritative origin, and a complete remote tag inventory. `--mode published` additionally verifies public release and archive evidence; a network, rate-limit, redirect, digest, or identity failure blocks rather than falling back to local success.
|
| 33 |
-
|
| 34 |
-
The gate performs bounded manifest, path, inventory, size, encoding, checksum, secret-signature, identity, Git, and tag checks before it executes the candidate validator or its behavioral regression suite. This prevents an untrusted or incomplete candidate from reaching the executable portion of the workflow merely because it can rewrite its own checksum file.
|
| 35 |
-
|
| 36 |
-
## Trust boundaries and non-goals
|
| 37 |
-
|
| 38 |
-
This repository accepts only statement-level aggregates. It is not designed to ingest source statements, cardholder data, bank data, merchant-owner data, credentials, or secrets. Automated pattern screening is defense in depth; it cannot prove arbitrary prose contains no identifying or confidential information. Human review remains mandatory before any record is made public.
|
| 39 |
-
|
| 40 |
-
The gate establishes reproducibility, internal consistency, and declared release provenance. It is not a malware sandbox, digital signature, accounting opinion, legal determination, interchange-qualification audit, or guarantee that a mapped source statement is complete. Run executable candidate validation only on a locally reviewed checkout. Published mode verifies release identity and bytes; it does not make arbitrary contributed Python safe to execute.
|
| 41 |
-
|
| 42 |
-
## Reporting a vulnerability
|
| 43 |
-
|
| 44 |
-
Use GitHub's private vulnerability reporting workflow in the repository Security tab. Do not include real merchant statements, PANs, authentication data, bank details, credentials, or other sensitive values in a report. A minimal synthetic reproducer is sufficient.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checksums.txt
DELETED
|
@@ -1,47 +0,0 @@
|
|
| 1 |
-
04ad658cdb6c353e0dc5370b6046cbb109cd32e70f855f3109e6d0b58f643fe9 .gitattributes
|
| 2 |
-
67e5ff8fcd780d06d5af0eea9e45446867acc7b59fad6fa804c75854d25a66bb .zenodo.json
|
| 3 |
-
7b4ec6231e50037e6768151e00c11bc0afc28af3dea6bd42719c41204093ab11 CHANGELOG.md
|
| 4 |
-
200160f0fe93775f2d46ba22d359789a86b3d73ec0826e5d6ebc20a18dcc3784 CITATION.cff
|
| 5 |
-
042fc2859745c561aac599568148651d52fa5723c61643fc6fd7cf4a7e9eac37 DATA_DICTIONARY.md
|
| 6 |
-
f5b745ef98087f531e719ee8ca6a96809444573ecc7173c6fa68eaad39b3cc3f LICENSE.md
|
| 7 |
-
e5fb71de92248b8867c8fd0f0f93e93aa4a3e5d2c968f0d5c95cc106f46f5489 METHODOLOGY.md
|
| 8 |
-
478c5db4ba9479afb78a55ff1021ecb538f05d1ba85d29172390f9e442168c4b README.md
|
| 9 |
-
dd7656da1e7d1a3a189c3f8bc37855beebbb2d55c42299d93a1f4f615c39e8ec RELEASE-MANIFEST.json
|
| 10 |
-
c0a99f8575f303bf54c8be9331e67ed28d74751982ff894148ffdf20240818de SECURITY.md
|
| 11 |
-
86be15179f7237bdf99bcfee7402dfc3930e30112d90004f4dc4c37353417baf codemeta.json
|
| 12 |
-
a97106304eef9d19e46743f7d302235fd7686566f76edb1082b786798ed949d5 distribution/huggingface/README.md
|
| 13 |
-
10f83fee3320bc731090b9bf6e582d8e6c6764414ff06ae0a8e8d1a9b57c8f62 distribution/kaggle/README.md
|
| 14 |
-
c5b24adf34e28e11aafa4975dbe37b653481346e3c228e1e844f45f04de46f53 distribution/kaggle/dataset-metadata.json
|
| 15 |
-
7a3299b4490d0e7f0c1a99a48859bce9742f632d8796699d80a48221e9fa38af examples/payment-statement-audit-example.json
|
| 16 |
-
2c8d4aad2ca52c2bd0014f1d7d3915e3eefb7d4dab02ae7fe33313673c725782 llms.txt
|
| 17 |
-
51cde2dd0d9da13e47c50228f96f8cc624662b5edcccb3f95719f53a79a1a47c payment-statement-audit-template.csv
|
| 18 |
-
d53f1737b5cb16cd8ad3c79ae4082ff35b0f120eb45bd502a042b3e5f275ac1f requirements-validation.txt
|
| 19 |
-
5979ec9c587be20ae723879f3863edb1f5a78ccddc848ca9a183b58532271730 schema/payment-statement-audit.schema.json
|
| 20 |
-
3bad5c0b256a0a65640515c00d6e1eea316039f57e3ec08a6809eee4c75f176a test-vectors/invalid/activity-mismatch.json
|
| 21 |
-
2ee2c9552d3728bcddce248cf3a3b8c12ec06c5923f48412688e544c69cdb78a test-vectors/invalid/duplicate-category.json
|
| 22 |
-
57f100181eb71060b16d3ae9e1861ef1eb79940f0bf7f4f1e618a97bb1e4415d test-vectors/invalid/fee-sum-mismatch.json
|
| 23 |
-
dd522dff07da399c5fc46d2d02a4cb9109c7f1860ec58a4849392e9aff853f52 test-vectors/invalid/fractional-cent.json
|
| 24 |
-
23c4e68b176b807df6738a4b0a9a8adbddbf9ddaee26d0b4262a6905652af951 test-vectors/invalid/invalid-date.json
|
| 25 |
-
0ef3f62501948cd15f7d69b4b64f43c78cb110f9937f5a2115e2e7e7f85eb0c7 test-vectors/invalid/net-fee-mismatch.json
|
| 26 |
-
caeb952d6e2c93597b6f7def52616e7b390c8f8807b9740a4ae6acb6ecba1d30 test-vectors/invalid/overlong-period.json
|
| 27 |
-
fb401b20ccfa0b3278948e60dbc7efc9e6c140d9facc7a58ddceb09ebfa32029 test-vectors/invalid/overprecise-rate.json
|
| 28 |
-
3733785277878384a097291b3dfbc4342ce0859cee2a73db8633e83ea2f730a6 test-vectors/invalid/pathological-number.json
|
| 29 |
-
96aa4e395b6fb9154673602441429aaf3cb3cb962899f3f9b355b4cfb0fb6d17 test-vectors/invalid/reversed-period.json
|
| 30 |
-
5a1821ccd329b53e393dd27d6eca8c4da7ed09f9963d36efe7eb2bfe7f47c0d9 test-vectors/invalid/security-data-in-note.json
|
| 31 |
-
a102b3b69c9260579982d5d668a57ab5494d1baba89fe8d93cd1b5ef5d564572 test-vectors/invalid/unknown-field.json
|
| 32 |
-
8520c8dc0244c121e85e39ae63af1846e15acf902355afa0ce515838c6160b7b test-vectors/invalid/wrong-average-ticket.json
|
| 33 |
-
b185d1eb11f805c1dac0e0a5aa69be8bb35fbed1079673a3e8a2abba45d83a36 test-vectors/invalid/wrong-effective-rate.json
|
| 34 |
-
7cf60eb7353825a9d21199f45860539590fb59a5c8964bd264e507b431d794f5 test-vectors/manifest.json
|
| 35 |
-
d73ed747b481e60c3c4502a1738997f04a6a5c63ceb1268ebd4e4fb8e3e0baea test-vectors/valid/standard-month.json
|
| 36 |
-
9a0f4872a6b588d246954727deb02bc5b7e82bac9921efb5ebf1e0b27a558a10 test-vectors/valid/zero-activity-month.json
|
| 37 |
-
c2ec930b5fed0fd75f239c72ad51d334ff6c003c1416a8191b21d80e84656ce3 tests/test_audit_validator.py
|
| 38 |
-
9aa1785145954aa93d345465827d577bfb7d92bf23ef357e5611b2d68eaa0aed tests/test_public_release_attestation.py
|
| 39 |
-
180a1d1d0a71a7167537e481b7746f6f5d4266bdb23029985141e329bde225ae tests/test_publication_gate.py
|
| 40 |
-
81d5d589cba17d88cae25c6994fbd35b509a599e50f3f7b7834b514e35681e2d tests/test_release_assets.py
|
| 41 |
-
8e286558ebebedac83adb98cd598ea671d28963316b2ef645de0ff5ce23e8728 tests/test_release_provenance.py
|
| 42 |
-
33e08a4723f556d04f0d83120c1bf628f89f5e711fb5735a66e3cad5b51dba00 tools/public_release_attestation.py
|
| 43 |
-
4440277885f5ada1beea10553732fe2f74f66e14c31eb1d2a2c71e34121cae98 tools/publication_gate.py
|
| 44 |
-
63068e495cd58f969b35cdfe67fb2810eff846482ec79a3edc6ca5be423ca4fb tools/release_provenance.py
|
| 45 |
-
9efff7ec3bfff067abaaf8a5d2c5008c3aaf0bf7b25c49ff623c37552de6bb10 tools/update_checksums.py
|
| 46 |
-
0fede54b398f6f58d7152592f47991855724b0af8d260e5a8bce000fb05be4cc tools/validate_audit.py
|
| 47 |
-
d5b203a020a9c1345322ba1445f80bd6ca777240562e891833cab7b3e776b794 validation-report.json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
codemeta.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
|
| 3 |
-
"@type": "Dataset",
|
| 4 |
-
"name": "Lifted Payments Payment Statement Audit Model",
|
| 5 |
-
"description": "A processor-neutral, validated model for normalizing monthly merchant payment-processing statements without cardholder data.",
|
| 6 |
-
"version": "1.1.3",
|
| 7 |
-
"datePublished": "2026-08-02",
|
| 8 |
-
"license": "https://creativecommons.org/licenses/by/4.0/",
|
| 9 |
-
"identifier": "https://doi.org/10.5281/zenodo.21764642",
|
| 10 |
-
"url": "https://liftedpayments.com/payment-processing-statement-audit/",
|
| 11 |
-
"sameAs": [
|
| 12 |
-
"https://doi.org/10.5281/zenodo.21764642",
|
| 13 |
-
"https://doi.org/10.5281/zenodo.21761714",
|
| 14 |
-
"https://zenodo.org/records/21764642"
|
| 15 |
-
],
|
| 16 |
-
"codeRepository": "https://github.com/Lifted-Holdings/payment-processing-resources",
|
| 17 |
-
"creator": {
|
| 18 |
-
"@type": "Organization",
|
| 19 |
-
"name": "Lifted Payments",
|
| 20 |
-
"url": "https://liftedpayments.com/"
|
| 21 |
-
},
|
| 22 |
-
"publisher": {
|
| 23 |
-
"@type": "Organization",
|
| 24 |
-
"name": "Lifted Holdings",
|
| 25 |
-
"url": "https://liftedholdings.com/"
|
| 26 |
-
},
|
| 27 |
-
"keywords": [
|
| 28 |
-
"payment processing",
|
| 29 |
-
"merchant services",
|
| 30 |
-
"effective rate",
|
| 31 |
-
"statement audit",
|
| 32 |
-
"fintech",
|
| 33 |
-
"JSON Schema",
|
| 34 |
-
"payments data",
|
| 35 |
-
"cost analysis"
|
| 36 |
-
],
|
| 37 |
-
"isAccessibleForFree": true,
|
| 38 |
-
"inLanguage": "en"
|
| 39 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
distribution/huggingface/README.md
DELETED
|
@@ -1,90 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: cc-by-4.0
|
| 3 |
-
language:
|
| 4 |
-
- en
|
| 5 |
-
pretty_name: "Lifted Payments Payment Statement Audit Model"
|
| 6 |
-
tags:
|
| 7 |
-
- tabular
|
| 8 |
-
- finance
|
| 9 |
-
- payments
|
| 10 |
-
- merchant-services
|
| 11 |
-
- effective-rate
|
| 12 |
-
configs:
|
| 13 |
-
- config_name: default
|
| 14 |
-
data_files:
|
| 15 |
-
- split: examples
|
| 16 |
-
path: examples/payment-statement-audit-example.json
|
| 17 |
-
---
|
| 18 |
-
|
| 19 |
-
# Lifted Payments Payment Statement Audit Model
|
| 20 |
-
|
| 21 |
-
A processor-neutral data contract for turning monthly merchant payment-processing totals into a consistent, comparable audit record. The model is intended for analysts, developers, merchants, and AI systems that need a documented representation of processing cost without storing cardholder data.
|
| 22 |
-
|
| 23 |
-
This distribution contains package version **1.1.3** and its schema **1.1.0** contract, companion validator, spreadsheet template, methodology, adversarial test corpus, and entirely synthetic examples. It is a reusable specification and demonstration package, not a collection of real merchant statements.
|
| 24 |
-
|
| 25 |
-
## Persistent identity
|
| 26 |
-
|
| 27 |
-
- Canonical methodology: https://liftedpayments.com/payment-processing-statement-audit/
|
| 28 |
-
- Version DOI: https://doi.org/10.5281/zenodo.21764642
|
| 29 |
-
- Concept DOI: https://doi.org/10.5281/zenodo.21761714
|
| 30 |
-
- Versioned source release: https://github.com/Lifted-Holdings/payment-processing-resources/releases/tag/v1.1.3
|
| 31 |
-
- Source repository: https://github.com/Lifted-Holdings/payment-processing-resources
|
| 32 |
-
|
| 33 |
-
## Files
|
| 34 |
-
|
| 35 |
-
| File | Role |
|
| 36 |
-
|---|---|
|
| 37 |
-
| `payment-statement-audit-template.csv` | Spreadsheet-ready header for one monthly audit record |
|
| 38 |
-
| `schema/payment-statement-audit.schema.json` | JSON Schema Draft 2020-12 validation contract |
|
| 39 |
-
| `examples/payment-statement-audit-example.json` | Complete synthetic example record |
|
| 40 |
-
| `DATA_DICTIONARY.md` and `METHODOLOGY.md` | Exact definitions, procedure, rounding, safety, and limitations |
|
| 41 |
-
| `tools/validate_audit.py` | Decimal-safe structural, accounting, and privacy validator |
|
| 42 |
-
| `test-vectors/` and `validation-report.json` | Reproducible acceptance/rejection corpus and result |
|
| 43 |
-
| `CITATION.cff` | Citation metadata |
|
| 44 |
-
| `codemeta.json` | Schema.org and CodeMeta dataset identity |
|
| 45 |
-
| `checksums.txt` | SHA-256 integrity values for the portable data files |
|
| 46 |
-
|
| 47 |
-
## Core fields
|
| 48 |
-
|
| 49 |
-
| Field | Meaning |
|
| 50 |
-
|---|---|
|
| 51 |
-
| `statement_period` | Start and end dates covered by the monthly statement |
|
| 52 |
-
| `card_volume` | Total card sales volume for the same period |
|
| 53 |
-
| `transaction_count` | Count of processed transactions |
|
| 54 |
-
| `gross_processing_fees` | Exact sum of gross fee-group charges |
|
| 55 |
-
| `statement_credits` | Processing-fee credits or rebates, reported separately |
|
| 56 |
-
| `total_processing_fees` | Gross fees minus statement credits |
|
| 57 |
-
| `effective_rate` | Net processing fees divided by gross settled purchase volume, stored as a decimal |
|
| 58 |
-
| `pricing_model` | The pricing structure observed in the statement |
|
| 59 |
-
| `fee_groups` | Fees grouped into stable comparison categories |
|
| 60 |
-
| `review_notes` | Analyst notes, assumptions, and data-quality boundaries |
|
| 61 |
-
|
| 62 |
-
The core calculation is:
|
| 63 |
-
|
| 64 |
-
```text
|
| 65 |
-
effective rate = net processing fees / gross settled purchase volume
|
| 66 |
-
```
|
| 67 |
-
|
| 68 |
-
For example, `0.022918` displays as `2.2918%` after multiplying by 100 for presentation.
|
| 69 |
-
|
| 70 |
-
## Intended uses
|
| 71 |
-
|
| 72 |
-
- Normalize statement totals before comparing months or proposals.
|
| 73 |
-
- Validate an audit record against a stable machine-readable schema.
|
| 74 |
-
- Build spreadsheet, Python, BI, or LLM-assisted review workflows around documented fields.
|
| 75 |
-
- Teach the difference between an effective rate and an advertised headline rate.
|
| 76 |
-
- Classify fees without assuming a particular processor, gateway, or pricing provider.
|
| 77 |
-
|
| 78 |
-
## Limitations and safety
|
| 79 |
-
|
| 80 |
-
The model does not determine legal compliance, tax treatment, network qualification, underwriting eligibility, accounting correctness, or future pricing. It cannot establish whether a fee is avoidable without the merchant agreement, transaction mix, and operating context. Automated privacy screening reduces accidental disclosure but cannot prove arbitrary notes contain no confidential information; a human review remains required before public release.
|
| 81 |
-
|
| 82 |
-
The included example is synthetic and describes no real merchant. Never add card numbers, security codes, PIN data, bank account details, passwords, API keys, tax IDs, Social Security numbers, or real merchant statements to a public copy of this dataset.
|
| 83 |
-
|
| 84 |
-
## Citation
|
| 85 |
-
|
| 86 |
-
> Lifted Payments. (2026). *Lifted Payments Payment Statement Audit Model* (Version 1.1.3). Zenodo. https://doi.org/10.5281/zenodo.21764642
|
| 87 |
-
|
| 88 |
-
## License
|
| 89 |
-
|
| 90 |
-
Released under [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/). Attribution is required when the model or its documentation is reused.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
distribution/kaggle/README.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
| 1 |
-
# Lifted Payments Payment Statement Audit Model
|
| 2 |
-
|
| 3 |
-
This is the Kaggle distribution of package version **1.1.3** and schema **1.1.0** of the Lifted Payments Payment Statement Audit Model: a processor-neutral CSV template, JSON Schema, companion validator, methodology, adversarial test corpus, and synthetic examples for normalizing monthly merchant payment-processing costs.
|
| 4 |
-
|
| 5 |
-
## Authoritative references
|
| 6 |
-
|
| 7 |
-
- Canonical methodology: https://liftedpayments.com/payment-processing-statement-audit/
|
| 8 |
-
- Version DOI: https://doi.org/10.5281/zenodo.21764642
|
| 9 |
-
- Concept DOI: https://doi.org/10.5281/zenodo.21761714
|
| 10 |
-
- Versioned source release: https://github.com/Lifted-Holdings/payment-processing-resources/releases/tag/v1.1.3
|
| 11 |
-
- Source repository: https://github.com/Lifted-Holdings/payment-processing-resources
|
| 12 |
-
|
| 13 |
-
## What the files do
|
| 14 |
-
|
| 15 |
-
- `payment-statement-audit-template.csv` supplies a spreadsheet-ready field header.
|
| 16 |
-
- `payment-statement-audit.schema.json` validates structured audit records.
|
| 17 |
-
- `payment-statement-audit-example.json` demonstrates a complete record using synthetic values.
|
| 18 |
-
- `DATA_DICTIONARY.md` and `METHODOLOGY.md` define every calculation, inclusion, exclusion, rounding rule, and limitation.
|
| 19 |
-
- `validate_audit.py`, the synthetic test vectors, and `validation-report.json` make acceptance and rejection behavior reproducible.
|
| 20 |
-
- `CITATION.cff`, `codemeta.json`, and `checksums.txt` preserve citation, entity identity, and file integrity.
|
| 21 |
-
|
| 22 |
-
Fee groups reconcile exactly to gross processing fees; processing-fee credits are separate. The effective rate is calculated as net processing fees divided by gross settled purchase volume. The JSON value is stored as a decimal and multiplied by 100 only for percentage display.
|
| 23 |
-
|
| 24 |
-
## Safety and limits
|
| 25 |
-
|
| 26 |
-
The example is synthetic and describes no real merchant. This package contains no cardholder data and must never be extended with real statements, card numbers, security codes, bank details, passwords, API keys, tax IDs, or owner Social Security numbers.
|
| 27 |
-
|
| 28 |
-
The model supports consistent analysis; it does not determine legal compliance, tax treatment, network qualification, underwriting eligibility, or guaranteed savings.
|
| 29 |
-
|
| 30 |
-
## Citation and license
|
| 31 |
-
|
| 32 |
-
> Lifted Payments. (2026). *Lifted Payments Payment Statement Audit Model* (Version 1.1.3). Zenodo. https://doi.org/10.5281/zenodo.21764642
|
| 33 |
-
|
| 34 |
-
Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
distribution/kaggle/dataset-metadata.json
DELETED
|
@@ -1,42 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"title": "Lifted Payments Payment Statement Audit Model",
|
| 3 |
-
"subtitle": "A processor-neutral schema and synthetic merchant statement audit example",
|
| 4 |
-
"description": "Package 1.1.3 of the Lifted Payments processor-neutral model for normalizing monthly merchant payment-processing statement totals, preserving the schema 1.1.0 record contract. The package contains a CSV template, JSON Schema Draft 2020-12 contract, Decimal-safe companion validator, methodology, synthetic adversarial vectors, reproducible validation report, citation metadata, and SHA-256 checksums. Canonical methodology: https://liftedpayments.com/payment-processing-statement-audit/ . Version DOI: https://doi.org/10.5281/zenodo.21764642 . No real merchant or cardholder data is included.",
|
| 5 |
-
"id": "liftedpayments/payment-statement-audit-model",
|
| 6 |
-
"licenses": [
|
| 7 |
-
{
|
| 8 |
-
"name": "CC-BY-4.0"
|
| 9 |
-
}
|
| 10 |
-
],
|
| 11 |
-
"resources": [
|
| 12 |
-
{
|
| 13 |
-
"path": "payment-statement-audit-template.csv",
|
| 14 |
-
"description": "Spreadsheet-ready header for one monthly payment statement audit record."
|
| 15 |
-
},
|
| 16 |
-
{
|
| 17 |
-
"path": "payment-statement-audit.schema.json",
|
| 18 |
-
"description": "JSON Schema Draft 2020-12 validation contract for audit records."
|
| 19 |
-
},
|
| 20 |
-
{
|
| 21 |
-
"path": "payment-statement-audit-example.json",
|
| 22 |
-
"description": "Complete synthetic example with no real merchant or cardholder data."
|
| 23 |
-
},
|
| 24 |
-
{
|
| 25 |
-
"path": "CITATION.cff",
|
| 26 |
-
"description": "Citation metadata for package version 1.1.3."
|
| 27 |
-
},
|
| 28 |
-
{
|
| 29 |
-
"path": "codemeta.json",
|
| 30 |
-
"description": "Schema.org and CodeMeta dataset identity."
|
| 31 |
-
},
|
| 32 |
-
{
|
| 33 |
-
"path": "checksums.txt",
|
| 34 |
-
"description": "SHA-256 integrity values for the portable source files."
|
| 35 |
-
}
|
| 36 |
-
],
|
| 37 |
-
"keywords": [
|
| 38 |
-
"finance",
|
| 39 |
-
"business",
|
| 40 |
-
"data analysis"
|
| 41 |
-
]
|
| 42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
examples/payment-statement-audit-example.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version": "1.1.0",
|
| 3 |
-
"calculation_basis": "gross_settled_purchase_volume_and_net_processing_fees",
|
| 4 |
-
"statement_period": { "start": "2026-06-01", "end": "2026-06-30" },
|
| 5 |
-
"currency": "USD",
|
| 6 |
-
"card_volume": 125000.00,
|
| 7 |
-
"transaction_count": 1860,
|
| 8 |
-
"gross_processing_fees": 2864.75,
|
| 9 |
-
"statement_credits": 0.00,
|
| 10 |
-
"total_processing_fees": 2864.75,
|
| 11 |
-
"effective_rate": 0.022918,
|
| 12 |
-
"average_ticket": 67.20,
|
| 13 |
-
"pricing_model": "interchange_plus",
|
| 14 |
-
"fee_groups": [
|
| 15 |
-
{ "category": "interchange", "amount": 1849.25, "notes": "Illustrative network interchange total." },
|
| 16 |
-
{ "category": "assessments", "amount": 171.50, "notes": "Illustrative network assessments." },
|
| 17 |
-
{ "category": "processor_markup", "amount": 575.00, "notes": "Illustrative percentage and per-item markup." },
|
| 18 |
-
{ "category": "authorization", "amount": 186.00, "notes": "Illustrative authorization fees." },
|
| 19 |
-
{ "category": "monthly", "amount": 49.00, "notes": "Illustrative account and statement fees." },
|
| 20 |
-
{ "category": "pci", "amount": 34.00, "notes": "Illustrative compliance-program fee." }
|
| 21 |
-
],
|
| 22 |
-
"review_notes": [
|
| 23 |
-
"All figures are synthetic and do not describe a real merchant.",
|
| 24 |
-
"Fee groups reconcile to gross processing fees; processing-fee credits are reported separately."
|
| 25 |
-
]
|
| 26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lifted-payments-statement-audit-model-v1.1.3.zip
DELETED
|
Binary file (85.5 kB)
|
|
|
lifted-payments-statement-audit-model-v1.1.4.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b92c00b9f0a5a36fcdd5c005f30cb4037de0c39e89ab9c32c229dfc71ffd801c
|
| 3 |
+
size 287396
|
llms.txt
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
# Lifted Payments open resources
|
| 2 |
-
|
| 3 |
-
This public repository contains a processor-neutral payment processing statement audit model from Lifted Payments.
|
| 4 |
-
|
| 5 |
-
Canonical guide: https://liftedpayments.com/payment-processing-statement-audit/
|
| 6 |
-
Version DOI: https://doi.org/10.5281/zenodo.21764642
|
| 7 |
-
Concept DOI: https://doi.org/10.5281/zenodo.21761714
|
| 8 |
-
Versioned release: https://github.com/Lifted-Holdings/payment-processing-resources/releases/tag/v1.1.3
|
| 9 |
-
Organization: https://liftedpayments.com/
|
| 10 |
-
Merchant application: https://liftedholdings.com/apply
|
| 11 |
-
License: CC BY 4.0
|
| 12 |
-
|
| 13 |
-
Files:
|
| 14 |
-
- payment-statement-audit-template.csv: spreadsheet-ready monthly statement summary.
|
| 15 |
-
- schema/payment-statement-audit.schema.json: JSON Schema Draft 2020-12 data contract.
|
| 16 |
-
- examples/payment-statement-audit-example.json: synthetic example; no real merchant or cardholder data.
|
| 17 |
-
- DATA_DICTIONARY.md: exact field, inclusion, exclusion, and fee-category definitions.
|
| 18 |
-
- METHODOLOGY.md: reproducible calculation, rounding, privacy, and limitation rules.
|
| 19 |
-
- tools/validate_audit.py: structural, accounting, and privacy validator using decimal arithmetic.
|
| 20 |
-
- validation-report.json: reproducible result for 2 valid and 14 invalid synthetic vectors.
|
| 21 |
-
- SECURITY.md: publication threat model, trust boundaries, and private reporting path.
|
| 22 |
-
- CITATION.cff: citation metadata.
|
| 23 |
-
|
| 24 |
-
Package 1.1.3 validates schema 1.1.0 records using gross settled purchase volume and net processing fees. Gross fee groups reconcile exactly; processing-fee credits are separate. Effective rate equals net processing fees divided by gross settled purchase volume, rounded half up to six decimal places. Store it as a decimal and multiply by 100 only for percentage display.
|
| 25 |
-
|
| 26 |
-
Never add card numbers, bank details, credentials, tax IDs, owner Social Security numbers, or real merchant statements to this public repository.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
payment-statement-audit-template.csv
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
schema_version,calculation_basis,statement_start,statement_end,currency,card_volume,transaction_count,gross_processing_fees,statement_credits,total_processing_fees,effective_rate,average_ticket,pricing_model,interchange,assessments,processor_markup,authorization,monthly,pci,equipment,chargebacks,other,notes
|
| 2 |
-
1.1.0,gross_settled_purchase_volume_and_net_processing_fees,2026-06-01,2026-06-30,USD,125000.00,1860,2864.75,0.00,2864.75,0.022918,67.20,interchange_plus,1849.25,171.50,575.00,186.00,49.00,34.00,0.00,0.00,0.00,Synthetic example only; replace every value with figures from your own statement
|
|
|
|
|
|
|
|
|
release-archive.sha256
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
b92c00b9f0a5a36fcdd5c005f30cb4037de0c39e89ab9c32c229dfc71ffd801c lifted-payments-statement-audit-model-v1.1.4.zip
|
requirements-validation.txt
DELETED
|
@@ -1,5 +0,0 @@
|
|
| 1 |
-
attrs==26.1.0
|
| 2 |
-
jsonschema==4.26.0
|
| 3 |
-
jsonschema-specifications==2025.9.1
|
| 4 |
-
referencing==0.37.0
|
| 5 |
-
rpds-py==2026.6.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
schema/payment-statement-audit.schema.json
DELETED
|
@@ -1,155 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
| 3 |
-
"$id": "https://liftedpayments.com/assets/data/payment-statement-audit.schema.json",
|
| 4 |
-
"title": "Lifted Payments Payment Statement Audit Model",
|
| 5 |
-
"description": "A processor-neutral contract for normalizing statement-level merchant processing totals without cardholder or bank-account data. Cross-field accounting and privacy rules are enforced by tools/validate_audit.py.",
|
| 6 |
-
"type": "object",
|
| 7 |
-
"required": [
|
| 8 |
-
"schema_version",
|
| 9 |
-
"calculation_basis",
|
| 10 |
-
"statement_period",
|
| 11 |
-
"currency",
|
| 12 |
-
"card_volume",
|
| 13 |
-
"transaction_count",
|
| 14 |
-
"gross_processing_fees",
|
| 15 |
-
"statement_credits",
|
| 16 |
-
"total_processing_fees",
|
| 17 |
-
"effective_rate",
|
| 18 |
-
"average_ticket",
|
| 19 |
-
"pricing_model",
|
| 20 |
-
"fee_groups"
|
| 21 |
-
],
|
| 22 |
-
"properties": {
|
| 23 |
-
"schema_version": {
|
| 24 |
-
"const": "1.1.0",
|
| 25 |
-
"description": "Version of this data contract."
|
| 26 |
-
},
|
| 27 |
-
"calculation_basis": {
|
| 28 |
-
"const": "gross_settled_purchase_volume_and_net_processing_fees",
|
| 29 |
-
"description": "Declares the numerator and denominator convention used by this release."
|
| 30 |
-
},
|
| 31 |
-
"statement_period": {
|
| 32 |
-
"type": "object",
|
| 33 |
-
"required": ["start", "end"],
|
| 34 |
-
"properties": {
|
| 35 |
-
"start": {
|
| 36 |
-
"type": "string",
|
| 37 |
-
"format": "date",
|
| 38 |
-
"description": "First calendar date covered by the statement, inclusive."
|
| 39 |
-
},
|
| 40 |
-
"end": {
|
| 41 |
-
"type": "string",
|
| 42 |
-
"format": "date",
|
| 43 |
-
"description": "Last calendar date covered by the statement, inclusive."
|
| 44 |
-
}
|
| 45 |
-
},
|
| 46 |
-
"additionalProperties": false
|
| 47 |
-
},
|
| 48 |
-
"currency": {
|
| 49 |
-
"const": "USD",
|
| 50 |
-
"description": "All monetary fields use US dollars. Mixed-currency records are invalid."
|
| 51 |
-
},
|
| 52 |
-
"card_volume": {
|
| 53 |
-
"$ref": "#/$defs/money",
|
| 54 |
-
"description": "Gross settled purchase volume for the statement period, before refunds, chargebacks, or funding adjustments."
|
| 55 |
-
},
|
| 56 |
-
"transaction_count": {
|
| 57 |
-
"type": "integer",
|
| 58 |
-
"minimum": 0,
|
| 59 |
-
"maximum": 1000000000,
|
| 60 |
-
"description": "Count of settled purchase transactions included in card_volume."
|
| 61 |
-
},
|
| 62 |
-
"gross_processing_fees": {
|
| 63 |
-
"$ref": "#/$defs/money",
|
| 64 |
-
"description": "Gross processing-related charges before statement_credits; equals the sum of fee_groups."
|
| 65 |
-
},
|
| 66 |
-
"statement_credits": {
|
| 67 |
-
"$ref": "#/$defs/money",
|
| 68 |
-
"description": "Processing-fee credits or rebates applied on the statement. Transaction refunds and funding adjustments are excluded."
|
| 69 |
-
},
|
| 70 |
-
"total_processing_fees": {
|
| 71 |
-
"$ref": "#/$defs/money",
|
| 72 |
-
"description": "Net processing fees: gross_processing_fees minus statement_credits."
|
| 73 |
-
},
|
| 74 |
-
"effective_rate": {
|
| 75 |
-
"description": "total_processing_fees divided by card_volume, expressed as a decimal rounded to six places; null when card_volume is zero.",
|
| 76 |
-
"oneOf": [
|
| 77 |
-
{ "$ref": "#/$defs/rate" },
|
| 78 |
-
{ "type": "null" }
|
| 79 |
-
]
|
| 80 |
-
},
|
| 81 |
-
"average_ticket": {
|
| 82 |
-
"description": "card_volume divided by transaction_count, rounded to cents; null when transaction_count is zero.",
|
| 83 |
-
"oneOf": [
|
| 84 |
-
{ "$ref": "#/$defs/money" },
|
| 85 |
-
{ "type": "null" }
|
| 86 |
-
]
|
| 87 |
-
},
|
| 88 |
-
"pricing_model": {
|
| 89 |
-
"type": "string",
|
| 90 |
-
"enum": [
|
| 91 |
-
"interchange_plus",
|
| 92 |
-
"flat_rate",
|
| 93 |
-
"tiered",
|
| 94 |
-
"subscription",
|
| 95 |
-
"dual_pricing",
|
| 96 |
-
"unknown"
|
| 97 |
-
],
|
| 98 |
-
"description": "Observed statement pricing presentation, not a legal or qualification determination."
|
| 99 |
-
},
|
| 100 |
-
"fee_groups": {
|
| 101 |
-
"type": "array",
|
| 102 |
-
"minItems": 1,
|
| 103 |
-
"maxItems": 9,
|
| 104 |
-
"description": "Gross, nonnegative processing charges grouped once by category. Categories must be unique.",
|
| 105 |
-
"items": {
|
| 106 |
-
"type": "object",
|
| 107 |
-
"required": ["category", "amount"],
|
| 108 |
-
"properties": {
|
| 109 |
-
"category": {
|
| 110 |
-
"type": "string",
|
| 111 |
-
"enum": [
|
| 112 |
-
"interchange",
|
| 113 |
-
"assessments",
|
| 114 |
-
"processor_markup",
|
| 115 |
-
"authorization",
|
| 116 |
-
"monthly",
|
| 117 |
-
"pci",
|
| 118 |
-
"equipment",
|
| 119 |
-
"chargebacks",
|
| 120 |
-
"other"
|
| 121 |
-
]
|
| 122 |
-
},
|
| 123 |
-
"amount": { "$ref": "#/$defs/money" },
|
| 124 |
-
"notes": { "$ref": "#/$defs/note" }
|
| 125 |
-
},
|
| 126 |
-
"additionalProperties": false
|
| 127 |
-
}
|
| 128 |
-
},
|
| 129 |
-
"review_notes": {
|
| 130 |
-
"type": "array",
|
| 131 |
-
"maxItems": 20,
|
| 132 |
-
"items": { "$ref": "#/$defs/note" },
|
| 133 |
-
"description": "Optional audit explanations only. Never include merchant identity, card data, bank data, credentials, or secrets."
|
| 134 |
-
}
|
| 135 |
-
},
|
| 136 |
-
"$defs": {
|
| 137 |
-
"money": {
|
| 138 |
-
"type": "number",
|
| 139 |
-
"minimum": 0,
|
| 140 |
-
"maximum": 999999999999.99,
|
| 141 |
-
"description": "A nonnegative USD amount with no more than two decimal places. Decimal precision is enforced by the companion validator."
|
| 142 |
-
},
|
| 143 |
-
"rate": {
|
| 144 |
-
"type": "number",
|
| 145 |
-
"minimum": 0,
|
| 146 |
-
"description": "A nonnegative decimal rate with no more than six decimal places."
|
| 147 |
-
},
|
| 148 |
-
"note": {
|
| 149 |
-
"type": "string",
|
| 150 |
-
"minLength": 1,
|
| 151 |
-
"maxLength": 500
|
| 152 |
-
}
|
| 153 |
-
},
|
| 154 |
-
"additionalProperties": false
|
| 155 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/activity-mismatch.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":0.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":null,"average_ticket":0.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/duplicate-category.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":0.020000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":1.00},{"category":"processor_markup","amount":1.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/fee-sum-mismatch.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.01,"statement_credits":0.00,"total_processing_fees":2.01,"effective_rate":0.020100,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/fractional-cent.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":100.001,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":0.020000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/invalid-date.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-02-01","end":"2026-02-30"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":0.020000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/net-fee-mismatch.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.50,"total_processing_fees":2.00,"effective_rate":0.020000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/overlong-period.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-01-01","end":"2026-04-01"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":0.020000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/overprecise-rate.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":0.0200001,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/pathological-number.json
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version": "1.1.0",
|
| 3 |
-
"card_volume": 1e-999999
|
| 4 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/reversed-period.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-07-01","end":"2026-06-30"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":0.020000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/security-data-in-note.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":0.020000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}],"review_notes":["Synthetic security-code label with digits: CVV 123"]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/unknown-field.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":0.020000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}],"merchant_name":"Do not collect this"
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/wrong-average-ticket.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":100.00,"transaction_count":2,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":0.020000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/invalid/wrong-effective-rate.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version":"1.1.0","calculation_basis":"gross_settled_purchase_volume_and_net_processing_fees","statement_period":{"start":"2026-06-01","end":"2026-06-30"},"currency":"USD","card_volume":100.00,"transaction_count":1,"gross_processing_fees":2.00,"statement_credits":0.00,"total_processing_fees":2.00,"effective_rate":2.000000,"average_ticket":100.00,"pricing_model":"flat_rate","fee_groups":[{"category":"processor_markup","amount":2.00}]
|
| 3 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/manifest.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"valid": [
|
| 3 |
-
"standard-month.json",
|
| 4 |
-
"zero-activity-month.json"
|
| 5 |
-
],
|
| 6 |
-
"invalid": {
|
| 7 |
-
"activity-mismatch.json": ["activity_pair"],
|
| 8 |
-
"duplicate-category.json": ["duplicate_fee_category"],
|
| 9 |
-
"fee-sum-mismatch.json": ["fee_group_reconciliation"],
|
| 10 |
-
"fractional-cent.json": ["money_precision"],
|
| 11 |
-
"invalid-date.json": ["schema_format"],
|
| 12 |
-
"net-fee-mismatch.json": ["net_fee_reconciliation"],
|
| 13 |
-
"overlong-period.json": ["period_duration"],
|
| 14 |
-
"overprecise-rate.json": ["rate_precision"],
|
| 15 |
-
"pathological-number.json": ["number_range"],
|
| 16 |
-
"security-data-in-note.json": ["prohibited_payment_data"],
|
| 17 |
-
"reversed-period.json": ["period_order"],
|
| 18 |
-
"unknown-field.json": ["schema_additionalProperties"],
|
| 19 |
-
"wrong-average-ticket.json": ["average_ticket_mismatch"],
|
| 20 |
-
"wrong-effective-rate.json": ["effective_rate_mismatch"]
|
| 21 |
-
}
|
| 22 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/valid/standard-month.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version": "1.1.0",
|
| 3 |
-
"calculation_basis": "gross_settled_purchase_volume_and_net_processing_fees",
|
| 4 |
-
"statement_period": {"start": "2026-06-01", "end": "2026-06-30"},
|
| 5 |
-
"currency": "USD",
|
| 6 |
-
"card_volume": 125000.00,
|
| 7 |
-
"transaction_count": 1860,
|
| 8 |
-
"gross_processing_fees": 2864.75,
|
| 9 |
-
"statement_credits": 0.00,
|
| 10 |
-
"total_processing_fees": 2864.75,
|
| 11 |
-
"effective_rate": 0.022918,
|
| 12 |
-
"average_ticket": 67.20,
|
| 13 |
-
"pricing_model": "interchange_plus",
|
| 14 |
-
"fee_groups": [
|
| 15 |
-
{"category": "interchange", "amount": 1849.25},
|
| 16 |
-
{"category": "assessments", "amount": 171.50},
|
| 17 |
-
{"category": "processor_markup", "amount": 575.00},
|
| 18 |
-
{"category": "authorization", "amount": 186.00},
|
| 19 |
-
{"category": "monthly", "amount": 49.00},
|
| 20 |
-
{"category": "pci", "amount": 34.00}
|
| 21 |
-
],
|
| 22 |
-
"review_notes": ["Synthetic validation vector only."]
|
| 23 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test-vectors/valid/zero-activity-month.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"schema_version": "1.1.0",
|
| 3 |
-
"calculation_basis": "gross_settled_purchase_volume_and_net_processing_fees",
|
| 4 |
-
"statement_period": {"start": "2026-06-01", "end": "2026-06-30"},
|
| 5 |
-
"currency": "USD",
|
| 6 |
-
"card_volume": 0.00,
|
| 7 |
-
"transaction_count": 0,
|
| 8 |
-
"gross_processing_fees": 49.00,
|
| 9 |
-
"statement_credits": 0.00,
|
| 10 |
-
"total_processing_fees": 49.00,
|
| 11 |
-
"effective_rate": null,
|
| 12 |
-
"average_ticket": null,
|
| 13 |
-
"pricing_model": "unknown",
|
| 14 |
-
"fee_groups": [{"category": "monthly", "amount": 49.00}],
|
| 15 |
-
"review_notes": ["Synthetic zero-activity validation vector only."]
|
| 16 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/__pycache__/test_audit_validator.cpython-312.pyc
DELETED
|
Binary file (32.6 kB)
|
|
|
tests/__pycache__/test_public_release_attestation.cpython-312.pyc
DELETED
|
Binary file (16 kB)
|
|
|
tests/__pycache__/test_publication_gate.cpython-312.pyc
DELETED
|
Binary file (37.5 kB)
|
|
|
tests/__pycache__/test_release_assets.cpython-312.pyc
DELETED
|
Binary file (17.5 kB)
|
|
|
tests/__pycache__/test_release_provenance.cpython-312.pyc
DELETED
|
Binary file (11.9 kB)
|
|
|
tests/test_audit_validator.py
DELETED
|
@@ -1,449 +0,0 @@
|
|
| 1 |
-
import copy
|
| 2 |
-
import importlib.util
|
| 3 |
-
import json
|
| 4 |
-
import shutil
|
| 5 |
-
import subprocess
|
| 6 |
-
import sys
|
| 7 |
-
import tempfile
|
| 8 |
-
import unittest
|
| 9 |
-
from decimal import Decimal, Inexact, localcontext
|
| 10 |
-
from pathlib import Path
|
| 11 |
-
|
| 12 |
-
from jsonschema import Draft202012Validator
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 16 |
-
SCHEMA_PATH = ROOT / "schema/payment-statement-audit.schema.json"
|
| 17 |
-
EXAMPLE_PATH = ROOT / "examples/payment-statement-audit-example.json"
|
| 18 |
-
VALIDATOR_PATH = ROOT / "tools/validate_audit.py"
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
def load_validator_module():
|
| 22 |
-
spec = importlib.util.spec_from_file_location("audit_validator", VALIDATOR_PATH)
|
| 23 |
-
if spec is None or spec.loader is None:
|
| 24 |
-
raise RuntimeError("Unable to load the audit validator")
|
| 25 |
-
module = importlib.util.module_from_spec(spec)
|
| 26 |
-
sys.modules[spec.name] = module
|
| 27 |
-
spec.loader.exec_module(module)
|
| 28 |
-
return module
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
class AuditValidatorTests(unittest.TestCase):
|
| 32 |
-
@classmethod
|
| 33 |
-
def setUpClass(cls):
|
| 34 |
-
if not VALIDATOR_PATH.is_file():
|
| 35 |
-
raise AssertionError("tools/validate_audit.py is required")
|
| 36 |
-
cls.validator = load_validator_module()
|
| 37 |
-
cls.valid_record = cls.validator.load_record(EXAMPLE_PATH)
|
| 38 |
-
|
| 39 |
-
def issue_codes(self, record):
|
| 40 |
-
return {issue.code for issue in self.validator.validate_record(record)}
|
| 41 |
-
|
| 42 |
-
def mutated(self, mutator):
|
| 43 |
-
record = copy.deepcopy(self.valid_record)
|
| 44 |
-
mutator(record)
|
| 45 |
-
return record
|
| 46 |
-
|
| 47 |
-
def test_schema_is_valid_draft_2020_12_and_example_passes_every_rule(self):
|
| 48 |
-
schema = json.loads(SCHEMA_PATH.read_text(encoding="utf-8"))
|
| 49 |
-
Draft202012Validator.check_schema(schema)
|
| 50 |
-
self.assertEqual([], self.validator.validate_record(self.valid_record))
|
| 51 |
-
|
| 52 |
-
def test_json_loader_preserves_decimals_and_rejects_duplicate_keys(self):
|
| 53 |
-
self.assertIsInstance(self.valid_record["card_volume"], Decimal)
|
| 54 |
-
duplicate = '{"schema_version":"1.1.0","schema_version":"1.1.0"}'
|
| 55 |
-
with self.assertRaisesRegex(ValueError, "duplicate_key"):
|
| 56 |
-
self.validator.loads_record(duplicate)
|
| 57 |
-
|
| 58 |
-
def test_reversed_and_overlong_statement_periods_are_rejected(self):
|
| 59 |
-
reversed_record = self.mutated(
|
| 60 |
-
lambda row: row["statement_period"].update(
|
| 61 |
-
{"start": "2026-07-01", "end": "2026-06-30"}
|
| 62 |
-
)
|
| 63 |
-
)
|
| 64 |
-
overlong_record = self.mutated(
|
| 65 |
-
lambda row: row["statement_period"].update(
|
| 66 |
-
{"start": "2026-01-01", "end": "2026-04-01"}
|
| 67 |
-
)
|
| 68 |
-
)
|
| 69 |
-
self.assertIn("period_order", self.issue_codes(reversed_record))
|
| 70 |
-
self.assertIn("period_duration", self.issue_codes(overlong_record))
|
| 71 |
-
|
| 72 |
-
def test_invalid_calendar_dates_are_rejected_even_when_schema_format_is_annotation(self):
|
| 73 |
-
record = self.mutated(
|
| 74 |
-
lambda row: row["statement_period"].update({"end": "2026-02-30"})
|
| 75 |
-
)
|
| 76 |
-
self.assertIn("schema_format", self.issue_codes(record))
|
| 77 |
-
|
| 78 |
-
def test_fee_categories_must_be_unique_and_reconcile_to_gross_fees(self):
|
| 79 |
-
duplicate = self.mutated(
|
| 80 |
-
lambda row: row["fee_groups"].append(copy.deepcopy(row["fee_groups"][0]))
|
| 81 |
-
)
|
| 82 |
-
mismatch = self.mutated(
|
| 83 |
-
lambda row: row.update({"gross_processing_fees": Decimal("2864.74")})
|
| 84 |
-
)
|
| 85 |
-
self.assertIn("duplicate_fee_category", self.issue_codes(duplicate))
|
| 86 |
-
self.assertIn("fee_group_reconciliation", self.issue_codes(mismatch))
|
| 87 |
-
|
| 88 |
-
def test_statement_credits_reconcile_gross_and_net_processing_fees(self):
|
| 89 |
-
valid_credit = self.mutated(
|
| 90 |
-
lambda row: row.update(
|
| 91 |
-
{
|
| 92 |
-
"statement_credits": Decimal("10.00"),
|
| 93 |
-
"total_processing_fees": Decimal("2854.75"),
|
| 94 |
-
"effective_rate": Decimal("0.022838"),
|
| 95 |
-
}
|
| 96 |
-
)
|
| 97 |
-
)
|
| 98 |
-
invalid_credit = self.mutated(
|
| 99 |
-
lambda row: row.update({"statement_credits": Decimal("10.00")})
|
| 100 |
-
)
|
| 101 |
-
self.assertEqual([], self.validator.validate_record(valid_credit))
|
| 102 |
-
self.assertIn("net_fee_reconciliation", self.issue_codes(invalid_credit))
|
| 103 |
-
|
| 104 |
-
def test_effective_rate_and_average_ticket_are_recomputed(self):
|
| 105 |
-
wrong_rate = self.mutated(
|
| 106 |
-
lambda row: row.update({"effective_rate": Decimal("2.291800")})
|
| 107 |
-
)
|
| 108 |
-
wrong_ticket = self.mutated(
|
| 109 |
-
lambda row: row.update({"average_ticket": Decimal("67.21")})
|
| 110 |
-
)
|
| 111 |
-
self.assertIn("effective_rate_mismatch", self.issue_codes(wrong_rate))
|
| 112 |
-
self.assertIn("average_ticket_mismatch", self.issue_codes(wrong_ticket))
|
| 113 |
-
|
| 114 |
-
def test_decimal_math_is_independent_of_the_callers_context(self):
|
| 115 |
-
with localcontext() as context:
|
| 116 |
-
context.prec = 4
|
| 117 |
-
context.Emax = 9
|
| 118 |
-
context.Emin = -9
|
| 119 |
-
context.traps[Inexact] = True
|
| 120 |
-
self.assertEqual([], self.validator.validate_record(self.valid_record))
|
| 121 |
-
|
| 122 |
-
def test_money_and_rate_precision_are_explicit(self):
|
| 123 |
-
fractional_cent = self.mutated(
|
| 124 |
-
lambda row: row.update({"card_volume": Decimal("125000.001")})
|
| 125 |
-
)
|
| 126 |
-
overprecise_rate = self.mutated(
|
| 127 |
-
lambda row: row.update({"effective_rate": Decimal("0.0229181")})
|
| 128 |
-
)
|
| 129 |
-
self.assertIn("money_precision", self.issue_codes(fractional_cent))
|
| 130 |
-
self.assertIn("rate_precision", self.issue_codes(overprecise_rate))
|
| 131 |
-
|
| 132 |
-
def test_zero_activity_semantics_are_unambiguous(self):
|
| 133 |
-
zero = self.mutated(
|
| 134 |
-
lambda row: row.update(
|
| 135 |
-
{
|
| 136 |
-
"card_volume": Decimal("0.00"),
|
| 137 |
-
"transaction_count": 0,
|
| 138 |
-
"gross_processing_fees": Decimal("49.00"),
|
| 139 |
-
"statement_credits": Decimal("0.00"),
|
| 140 |
-
"total_processing_fees": Decimal("49.00"),
|
| 141 |
-
"effective_rate": None,
|
| 142 |
-
"average_ticket": None,
|
| 143 |
-
"fee_groups": [
|
| 144 |
-
{"category": "monthly", "amount": Decimal("49.00")}
|
| 145 |
-
],
|
| 146 |
-
}
|
| 147 |
-
)
|
| 148 |
-
)
|
| 149 |
-
inconsistent = self.mutated(
|
| 150 |
-
lambda row: row.update(
|
| 151 |
-
{"card_volume": Decimal("0.00"), "effective_rate": None}
|
| 152 |
-
)
|
| 153 |
-
)
|
| 154 |
-
self.assertEqual([], self.validator.validate_record(zero))
|
| 155 |
-
self.assertIn("activity_pair", self.issue_codes(inconsistent))
|
| 156 |
-
|
| 157 |
-
zero_fee = self.mutated(
|
| 158 |
-
lambda row: row.update(
|
| 159 |
-
{
|
| 160 |
-
"card_volume": Decimal("0.00"),
|
| 161 |
-
"transaction_count": 0,
|
| 162 |
-
"gross_processing_fees": Decimal("0.00"),
|
| 163 |
-
"statement_credits": Decimal("0.00"),
|
| 164 |
-
"total_processing_fees": Decimal("0.00"),
|
| 165 |
-
"effective_rate": None,
|
| 166 |
-
"average_ticket": None,
|
| 167 |
-
"fee_groups": [
|
| 168 |
-
{"category": "other", "amount": Decimal("0.00")}
|
| 169 |
-
],
|
| 170 |
-
}
|
| 171 |
-
)
|
| 172 |
-
)
|
| 173 |
-
self.assertEqual([], self.validator.validate_record(zero_fee))
|
| 174 |
-
|
| 175 |
-
def test_published_half_up_rounding_is_enforced_at_exact_ties(self):
|
| 176 |
-
average_ticket_tie = self.mutated(
|
| 177 |
-
lambda row: row.update(
|
| 178 |
-
{
|
| 179 |
-
"card_volume": Decimal("0.01"),
|
| 180 |
-
"transaction_count": 2,
|
| 181 |
-
"gross_processing_fees": Decimal("0.00"),
|
| 182 |
-
"statement_credits": Decimal("0.00"),
|
| 183 |
-
"total_processing_fees": Decimal("0.00"),
|
| 184 |
-
"effective_rate": Decimal("0.000000"),
|
| 185 |
-
"average_ticket": Decimal("0.01"),
|
| 186 |
-
"fee_groups": [
|
| 187 |
-
{"category": "other", "amount": Decimal("0.00")}
|
| 188 |
-
],
|
| 189 |
-
}
|
| 190 |
-
)
|
| 191 |
-
)
|
| 192 |
-
effective_rate_tie = self.mutated(
|
| 193 |
-
lambda row: row.update(
|
| 194 |
-
{
|
| 195 |
-
"card_volume": Decimal("20000.00"),
|
| 196 |
-
"transaction_count": 1,
|
| 197 |
-
"gross_processing_fees": Decimal("0.01"),
|
| 198 |
-
"statement_credits": Decimal("0.00"),
|
| 199 |
-
"total_processing_fees": Decimal("0.01"),
|
| 200 |
-
"effective_rate": Decimal("0.000001"),
|
| 201 |
-
"average_ticket": Decimal("20000.00"),
|
| 202 |
-
"fee_groups": [
|
| 203 |
-
{"category": "other", "amount": Decimal("0.01")}
|
| 204 |
-
],
|
| 205 |
-
}
|
| 206 |
-
)
|
| 207 |
-
)
|
| 208 |
-
self.assertEqual([], self.validator.validate_record(average_ticket_tie))
|
| 209 |
-
self.assertEqual([], self.validator.validate_record(effective_rate_tie))
|
| 210 |
-
|
| 211 |
-
def test_non_finite_numbers_and_unknown_fields_are_rejected(self):
|
| 212 |
-
with self.assertRaisesRegex(ValueError, "non_finite_number"):
|
| 213 |
-
self.validator.loads_record('{"card_volume": NaN}')
|
| 214 |
-
unknown = self.mutated(lambda row: row.update({"merchant_name": "Example"}))
|
| 215 |
-
self.assertIn("schema_additionalProperties", self.issue_codes(unknown))
|
| 216 |
-
|
| 217 |
-
def test_pathological_number_literals_fail_closed_without_decimal_crashes(self):
|
| 218 |
-
hostile_literals = (
|
| 219 |
-
'{"card_volume":1e-999999}',
|
| 220 |
-
'{"effective_rate":1e999999}',
|
| 221 |
-
'{"transaction_count":' + ("9" * 5000) + "}",
|
| 222 |
-
)
|
| 223 |
-
for source in hostile_literals:
|
| 224 |
-
with self.subTest(source_length=len(source)):
|
| 225 |
-
with self.assertRaisesRegex(ValueError, "number_range"):
|
| 226 |
-
self.validator.loads_record(source)
|
| 227 |
-
|
| 228 |
-
direct_record = self.mutated(
|
| 229 |
-
lambda row: row.update({"card_volume": Decimal("1e-999999")})
|
| 230 |
-
)
|
| 231 |
-
self.assertIn("number_range", self.issue_codes(direct_record))
|
| 232 |
-
|
| 233 |
-
def test_direct_nonfinite_and_extreme_numbers_are_safe_rejections(self):
|
| 234 |
-
hostile_values = (
|
| 235 |
-
Decimal("Infinity"),
|
| 236 |
-
Decimal("NaN"),
|
| 237 |
-
Decimal("1e999999"),
|
| 238 |
-
float("inf"),
|
| 239 |
-
float("nan"),
|
| 240 |
-
10**32,
|
| 241 |
-
10**5000,
|
| 242 |
-
)
|
| 243 |
-
for value in hostile_values:
|
| 244 |
-
with self.subTest(value_type=type(value).__name__):
|
| 245 |
-
record = self.mutated(
|
| 246 |
-
lambda row, hostile=value: row.update({"card_volume": hostile})
|
| 247 |
-
)
|
| 248 |
-
self.assertIn("number_range", self.issue_codes(record))
|
| 249 |
-
|
| 250 |
-
def test_oversized_and_deeply_nested_inputs_fail_closed(self):
|
| 251 |
-
oversized = '{"review_notes":["' + ("x" * 1_000_000) + '"]}'
|
| 252 |
-
with self.assertRaisesRegex(ValueError, "input_size"):
|
| 253 |
-
self.validator.loads_record(oversized)
|
| 254 |
-
|
| 255 |
-
nested = "{}"
|
| 256 |
-
for _ in range(40):
|
| 257 |
-
nested = '{"unknown":' + nested + "}"
|
| 258 |
-
with self.assertRaisesRegex(ValueError, "input_depth"):
|
| 259 |
-
self.validator.loads_record(nested)
|
| 260 |
-
|
| 261 |
-
def test_malformed_nested_shapes_return_issues_instead_of_crashing(self):
|
| 262 |
-
malformed_records = [
|
| 263 |
-
{"statement_period": []},
|
| 264 |
-
{"fee_groups": [None, [], {"amount": []}]},
|
| 265 |
-
{"statement_period": {"start": [], "end": {}}},
|
| 266 |
-
{"review_notes": [{"unexpected": [1, 2, 3]}]},
|
| 267 |
-
]
|
| 268 |
-
for record in malformed_records:
|
| 269 |
-
with self.subTest(record=record):
|
| 270 |
-
issues = self.validator.validate_record(record)
|
| 271 |
-
self.assertTrue(issues)
|
| 272 |
-
|
| 273 |
-
def test_luhn_pan_and_contextual_security_data_in_notes_are_rejected(self):
|
| 274 |
-
pan = self.mutated(
|
| 275 |
-
lambda row: row.update(
|
| 276 |
-
{"review_notes": ["Card number 4111 1111 1111 1111"]}
|
| 277 |
-
)
|
| 278 |
-
)
|
| 279 |
-
cvv = self.mutated(
|
| 280 |
-
lambda row: row.update({"review_notes": ["CVV 123"]})
|
| 281 |
-
)
|
| 282 |
-
self.assertIn("prohibited_payment_data", self.issue_codes(pan))
|
| 283 |
-
self.assertIn("prohibited_payment_data", self.issue_codes(cvv))
|
| 284 |
-
|
| 285 |
-
def test_identity_bank_and_credential_values_in_notes_are_rejected(self):
|
| 286 |
-
prohibited_notes = (
|
| 287 |
-
"Owner email is merchant@example.com",
|
| 288 |
-
"Owner SSN is 123-45-6789",
|
| 289 |
-
"Routing number: 021000021",
|
| 290 |
-
"Password is CorrectHorseBatteryStaple",
|
| 291 |
-
)
|
| 292 |
-
for note in prohibited_notes:
|
| 293 |
-
with self.subTest(note_kind=note.split()[0].lower()):
|
| 294 |
-
record = self.mutated(
|
| 295 |
-
lambda row, value=note: row.update({"review_notes": [value]})
|
| 296 |
-
)
|
| 297 |
-
self.assertIn("prohibited_payment_data", self.issue_codes(record))
|
| 298 |
-
|
| 299 |
-
def test_errors_never_echo_input_values(self):
|
| 300 |
-
sensitive = "4111 1111 1111 1111"
|
| 301 |
-
record = self.mutated(
|
| 302 |
-
lambda row: row.update({"review_notes": [f"Card number {sensitive}"]})
|
| 303 |
-
)
|
| 304 |
-
report = self.validator.validation_result(record)
|
| 305 |
-
rendered = json.dumps(report, sort_keys=True)
|
| 306 |
-
self.assertNotIn(sensitive, rendered)
|
| 307 |
-
self.assertEqual("invalid", report["status"])
|
| 308 |
-
|
| 309 |
-
def test_unknown_field_names_never_leak_through_issue_paths(self):
|
| 310 |
-
sensitive_key = "password_SUPERSECRET_12345"
|
| 311 |
-
record = {sensitive_key: Decimal("1e999999")}
|
| 312 |
-
rendered = json.dumps(
|
| 313 |
-
self.validator.validation_result(record), sort_keys=True
|
| 314 |
-
)
|
| 315 |
-
self.assertNotIn(sensitive_key, rendered)
|
| 316 |
-
self.assertIn("/_unknown", rendered)
|
| 317 |
-
|
| 318 |
-
def test_csv_header_matches_the_documented_flat_contract(self):
|
| 319 |
-
issues = self.validator.validate_csv_template(
|
| 320 |
-
ROOT / "payment-statement-audit-template.csv"
|
| 321 |
-
)
|
| 322 |
-
self.assertEqual([], issues)
|
| 323 |
-
|
| 324 |
-
def test_csv_rejects_spreadsheet_formula_payloads_without_echoing_them(self):
|
| 325 |
-
formula_prefixes = (
|
| 326 |
-
"=1+1",
|
| 327 |
-
"+1+1",
|
| 328 |
-
"-1+1",
|
| 329 |
-
"@SUM(1)",
|
| 330 |
-
"\t=1+1",
|
| 331 |
-
"\ufeff=1+1",
|
| 332 |
-
)
|
| 333 |
-
for marker in formula_prefixes:
|
| 334 |
-
with self.subTest(prefix=marker[0]):
|
| 335 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 336 |
-
candidate = Path(directory) / "statement.csv"
|
| 337 |
-
source = (
|
| 338 |
-
ROOT / "payment-statement-audit-template.csv"
|
| 339 |
-
).read_text(encoding="utf-8")
|
| 340 |
-
lines = source.splitlines()
|
| 341 |
-
lines[1] = lines[1].rsplit(",", maxsplit=1)[0] + "," + marker
|
| 342 |
-
candidate.write_text(
|
| 343 |
-
"\n".join(lines) + "\n", encoding="utf-8"
|
| 344 |
-
)
|
| 345 |
-
|
| 346 |
-
issues = self.validator.validate_csv_template(candidate)
|
| 347 |
-
self.assertIn("csv_formula", {issue.code for issue in issues})
|
| 348 |
-
self.assertNotIn(
|
| 349 |
-
marker, json.dumps([issue.to_dict() for issue in issues])
|
| 350 |
-
)
|
| 351 |
-
|
| 352 |
-
def test_shipped_corpus_has_broad_expected_failure_coverage(self):
|
| 353 |
-
report = self.validator.build_corpus_report(ROOT)
|
| 354 |
-
self.assertEqual("pass", report["status"])
|
| 355 |
-
self.assertGreaterEqual(report["valid_vectors"], 2)
|
| 356 |
-
self.assertGreaterEqual(report["invalid_vectors"], 12)
|
| 357 |
-
self.assertEqual(0, report["unexpected_results"])
|
| 358 |
-
self.assertIn("schema_sha256", report)
|
| 359 |
-
self.assertIn("validator_sha256", report)
|
| 360 |
-
|
| 361 |
-
def test_corpus_report_records_the_complete_pinned_validation_runtime(self):
|
| 362 |
-
report = self.validator.build_corpus_report(ROOT)
|
| 363 |
-
expected = {
|
| 364 |
-
"attrs",
|
| 365 |
-
"jsonschema",
|
| 366 |
-
"jsonschema-specifications",
|
| 367 |
-
"referencing",
|
| 368 |
-
"rpds-py",
|
| 369 |
-
}
|
| 370 |
-
self.assertEqual(expected, set(report["dependency_versions"]))
|
| 371 |
-
pins = {
|
| 372 |
-
line.split("==", maxsplit=1)[0]: line.split("==", maxsplit=1)[1]
|
| 373 |
-
for line in (ROOT / "requirements-validation.txt")
|
| 374 |
-
.read_text(encoding="utf-8")
|
| 375 |
-
.splitlines()
|
| 376 |
-
if line and not line.startswith("#")
|
| 377 |
-
}
|
| 378 |
-
self.assertEqual(report["dependency_versions"], pins)
|
| 379 |
-
|
| 380 |
-
def test_cli_returns_nonzero_and_machine_readable_safe_output_for_invalid_input(self):
|
| 381 |
-
invalid_path = ROOT / "test-vectors/invalid/security-data-in-note.json"
|
| 382 |
-
result = subprocess.run(
|
| 383 |
-
[sys.executable, str(VALIDATOR_PATH), "--json", str(invalid_path)],
|
| 384 |
-
cwd=ROOT,
|
| 385 |
-
capture_output=True,
|
| 386 |
-
text=True,
|
| 387 |
-
encoding="utf-8",
|
| 388 |
-
)
|
| 389 |
-
self.assertEqual(1, result.returncode)
|
| 390 |
-
report = json.loads(result.stdout)
|
| 391 |
-
self.assertEqual("invalid", report["status"])
|
| 392 |
-
self.assertNotIn("4111", result.stdout)
|
| 393 |
-
|
| 394 |
-
def test_cli_uses_a_stable_value_free_code_for_unreadable_input(self):
|
| 395 |
-
marker = "private-merchant-statement-do-not-echo.json"
|
| 396 |
-
result = subprocess.run(
|
| 397 |
-
[sys.executable, str(VALIDATOR_PATH), "--json", str(ROOT / marker)],
|
| 398 |
-
cwd=ROOT,
|
| 399 |
-
capture_output=True,
|
| 400 |
-
text=True,
|
| 401 |
-
encoding="utf-8",
|
| 402 |
-
)
|
| 403 |
-
self.assertEqual(1, result.returncode)
|
| 404 |
-
report = json.loads(result.stdout)
|
| 405 |
-
self.assertEqual("input_read", report["issues"][0]["code"])
|
| 406 |
-
self.assertNotIn(marker, result.stdout)
|
| 407 |
-
|
| 408 |
-
def test_corpus_reports_a_missing_vector_without_throwing(self):
|
| 409 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 410 |
-
candidate = Path(directory) / "release"
|
| 411 |
-
shutil.copytree(ROOT, candidate)
|
| 412 |
-
(candidate / "test-vectors/invalid/wrong-effective-rate.json").unlink()
|
| 413 |
-
|
| 414 |
-
report = self.validator.build_corpus_report(candidate)
|
| 415 |
-
self.assertEqual("fail", report["status"])
|
| 416 |
-
self.assertGreaterEqual(report["unexpected_results"], 1)
|
| 417 |
-
|
| 418 |
-
def test_corpus_rejects_a_missing_registered_valid_vector(self):
|
| 419 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 420 |
-
candidate = Path(directory) / "release"
|
| 421 |
-
shutil.copytree(ROOT, candidate)
|
| 422 |
-
(candidate / "test-vectors/valid/standard-month.json").unlink()
|
| 423 |
-
|
| 424 |
-
report = self.validator.build_corpus_report(candidate)
|
| 425 |
-
self.assertEqual("fail", report["status"])
|
| 426 |
-
self.assertIn(
|
| 427 |
-
{"file": "valid-corpus", "result": "inventory_mismatch"},
|
| 428 |
-
report["unexpected"],
|
| 429 |
-
)
|
| 430 |
-
|
| 431 |
-
def test_corpus_rejects_an_unregistered_invalid_vector(self):
|
| 432 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 433 |
-
candidate = Path(directory) / "release"
|
| 434 |
-
shutil.copytree(ROOT, candidate)
|
| 435 |
-
shutil.copyfile(
|
| 436 |
-
candidate / "test-vectors/valid/standard-month.json",
|
| 437 |
-
candidate / "test-vectors/invalid/unregistered.json",
|
| 438 |
-
)
|
| 439 |
-
|
| 440 |
-
report = self.validator.build_corpus_report(candidate)
|
| 441 |
-
self.assertEqual("fail", report["status"])
|
| 442 |
-
self.assertIn(
|
| 443 |
-
{"file": "invalid-corpus", "result": "inventory_mismatch"},
|
| 444 |
-
report["unexpected"],
|
| 445 |
-
)
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
if __name__ == "__main__":
|
| 449 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_public_release_attestation.py
DELETED
|
@@ -1,329 +0,0 @@
|
|
| 1 |
-
import hashlib
|
| 2 |
-
import importlib.util
|
| 3 |
-
import io
|
| 4 |
-
import sys
|
| 5 |
-
import tempfile
|
| 6 |
-
import unittest
|
| 7 |
-
import zipfile
|
| 8 |
-
from pathlib import Path
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 12 |
-
ATTESTATION_PATH = ROOT / "tools/public_release_attestation.py"
|
| 13 |
-
TITLE = "Lifted Payments Payment Statement Audit Model"
|
| 14 |
-
CANONICAL_URL = "https://liftedpayments.com/payment-processing-statement-audit/"
|
| 15 |
-
SOURCE_REPOSITORY = "https://github.com/Lifted-Holdings/payment-processing-resources"
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
def load_module(path: Path, name: str):
|
| 19 |
-
spec = importlib.util.spec_from_file_location(name, path)
|
| 20 |
-
if spec is None or spec.loader is None:
|
| 21 |
-
raise RuntimeError(f"Unable to load {name}")
|
| 22 |
-
module = importlib.util.module_from_spec(spec)
|
| 23 |
-
sys.modules[spec.name] = module
|
| 24 |
-
spec.loader.exec_module(module)
|
| 25 |
-
return module
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
class FakeTransport:
|
| 29 |
-
def __init__(self, *, json_values, byte_values, final_urls):
|
| 30 |
-
self.json_values = json_values
|
| 31 |
-
self.byte_values = byte_values
|
| 32 |
-
self.final_urls = final_urls
|
| 33 |
-
|
| 34 |
-
def get_json(self, url, *, max_bytes):
|
| 35 |
-
del max_bytes
|
| 36 |
-
return self.json_values[url]
|
| 37 |
-
|
| 38 |
-
def get_bytes(self, url, *, max_bytes):
|
| 39 |
-
value = self.byte_values[url]
|
| 40 |
-
if len(value) > max_bytes:
|
| 41 |
-
raise ValueError("response_too_large")
|
| 42 |
-
return value
|
| 43 |
-
|
| 44 |
-
def resolve(self, url, *, max_bytes):
|
| 45 |
-
del max_bytes
|
| 46 |
-
return self.final_urls[url]
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
class PublicReleaseAttestationTests(unittest.TestCase):
|
| 50 |
-
@classmethod
|
| 51 |
-
def setUpClass(cls):
|
| 52 |
-
if not ATTESTATION_PATH.is_file():
|
| 53 |
-
raise AssertionError("tools/public_release_attestation.py is required")
|
| 54 |
-
cls.attestation = load_module(ATTESTATION_PATH, "public_release_attestation")
|
| 55 |
-
|
| 56 |
-
def setUp(self):
|
| 57 |
-
self.temporary_directory = tempfile.TemporaryDirectory()
|
| 58 |
-
self.root = Path(self.temporary_directory.name)
|
| 59 |
-
(self.root / "README.md").write_text("verified release\n", encoding="utf-8")
|
| 60 |
-
self.manifest = {
|
| 61 |
-
"title": TITLE,
|
| 62 |
-
"version": "1.1.3",
|
| 63 |
-
"release_date": "2026-08-02",
|
| 64 |
-
"version_doi": "10.5281/zenodo.99999999",
|
| 65 |
-
"concept_doi": "10.5281/zenodo.21761714",
|
| 66 |
-
"canonical_url": CANONICAL_URL,
|
| 67 |
-
"source_release": f"{SOURCE_REPOSITORY}/releases/tag/v1.1.3",
|
| 68 |
-
"license": "CC-BY-4.0",
|
| 69 |
-
"files": ["README.md"],
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
def tearDown(self):
|
| 73 |
-
self.temporary_directory.cleanup()
|
| 74 |
-
|
| 75 |
-
def make_zip(self, members=None):
|
| 76 |
-
members = members or {"README.md": (self.root / "README.md").read_bytes()}
|
| 77 |
-
output = io.BytesIO()
|
| 78 |
-
with zipfile.ZipFile(output, "w", compression=zipfile.ZIP_DEFLATED) as archive:
|
| 79 |
-
for name, value in members.items():
|
| 80 |
-
archive.writestr(f"payment-processing-resources-1.1.3/{name}", value)
|
| 81 |
-
return output.getvalue()
|
| 82 |
-
|
| 83 |
-
def make_transport(self, archive=None):
|
| 84 |
-
archive = archive or self.make_zip()
|
| 85 |
-
digest = hashlib.sha256(archive).hexdigest()
|
| 86 |
-
zip_name = "lifted-payments-statement-audit-model-v1.1.3.zip"
|
| 87 |
-
sidecar_name = "release-archive.sha256"
|
| 88 |
-
github_zip = (
|
| 89 |
-
f"https://github.com/Lifted-Holdings/payment-processing-resources/"
|
| 90 |
-
f"releases/download/v1.1.3/{zip_name}"
|
| 91 |
-
)
|
| 92 |
-
github_sidecar = (
|
| 93 |
-
"https://github.com/Lifted-Holdings/payment-processing-resources/"
|
| 94 |
-
f"releases/download/v1.1.3/{sidecar_name}"
|
| 95 |
-
)
|
| 96 |
-
zenodo_zip = (
|
| 97 |
-
f"https://zenodo.org/api/records/99999999/files/{zip_name}/content"
|
| 98 |
-
)
|
| 99 |
-
zenodo_sidecar = (
|
| 100 |
-
f"https://zenodo.org/api/records/99999999/files/{sidecar_name}/content"
|
| 101 |
-
)
|
| 102 |
-
huggingface_zip = (
|
| 103 |
-
"https://huggingface.co/datasets/Liftedholdings/"
|
| 104 |
-
f"payment-statement-audit-model/resolve/main/{zip_name}"
|
| 105 |
-
)
|
| 106 |
-
sidecar = f"{digest} {zip_name}\n".encode()
|
| 107 |
-
github = {
|
| 108 |
-
"tag_name": "v1.1.3",
|
| 109 |
-
"draft": False,
|
| 110 |
-
"prerelease": False,
|
| 111 |
-
"html_url": self.manifest["source_release"],
|
| 112 |
-
"assets": [
|
| 113 |
-
{
|
| 114 |
-
"name": zip_name,
|
| 115 |
-
"size": len(archive),
|
| 116 |
-
"digest": f"sha256:{digest}",
|
| 117 |
-
"browser_download_url": github_zip,
|
| 118 |
-
},
|
| 119 |
-
{
|
| 120 |
-
"name": sidecar_name,
|
| 121 |
-
"size": len(sidecar),
|
| 122 |
-
"digest": f"sha256:{hashlib.sha256(sidecar).hexdigest()}",
|
| 123 |
-
"browser_download_url": github_sidecar,
|
| 124 |
-
},
|
| 125 |
-
],
|
| 126 |
-
}
|
| 127 |
-
zenodo = {
|
| 128 |
-
"id": 99999999,
|
| 129 |
-
"doi": self.manifest["version_doi"],
|
| 130 |
-
"conceptdoi": self.manifest["concept_doi"],
|
| 131 |
-
"metadata": {
|
| 132 |
-
"title": TITLE,
|
| 133 |
-
"publication_date": "2026-08-02",
|
| 134 |
-
"version": "1.1.3",
|
| 135 |
-
"license": {"id": "cc-by-4.0"},
|
| 136 |
-
"related_identifiers": [
|
| 137 |
-
{"identifier": CANONICAL_URL, "relation": "isDocumentedBy"},
|
| 138 |
-
{
|
| 139 |
-
"identifier": self.manifest["source_release"],
|
| 140 |
-
"relation": "isSourceOf",
|
| 141 |
-
},
|
| 142 |
-
],
|
| 143 |
-
},
|
| 144 |
-
"files": [
|
| 145 |
-
{
|
| 146 |
-
"key": zip_name,
|
| 147 |
-
"size": len(archive),
|
| 148 |
-
"checksum": f"md5:{hashlib.md5(archive).hexdigest()}",
|
| 149 |
-
"links": {"self": zenodo_zip},
|
| 150 |
-
},
|
| 151 |
-
{
|
| 152 |
-
"key": sidecar_name,
|
| 153 |
-
"size": len(sidecar),
|
| 154 |
-
"checksum": f"md5:{hashlib.md5(sidecar).hexdigest()}",
|
| 155 |
-
"links": {"self": zenodo_sidecar},
|
| 156 |
-
},
|
| 157 |
-
],
|
| 158 |
-
}
|
| 159 |
-
huggingface = {
|
| 160 |
-
"id": "Liftedholdings/payment-statement-audit-model",
|
| 161 |
-
"sha": "a" * 40,
|
| 162 |
-
"private": False,
|
| 163 |
-
"disabled": False,
|
| 164 |
-
"gated": False,
|
| 165 |
-
"siblings": [{"rfilename": zip_name}],
|
| 166 |
-
}
|
| 167 |
-
snapshot_id = "c" * 40
|
| 168 |
-
release_id = "d" * 40
|
| 169 |
-
expected_commit = "b" * 40
|
| 170 |
-
software_heritage_visit = (
|
| 171 |
-
"https://archive.softwareheritage.org/api/1/origin/"
|
| 172 |
-
"https%3A%2F%2Fgithub.com%2FLifted-Holdings%2F"
|
| 173 |
-
"payment-processing-resources/visit/latest/?require_snapshot=true"
|
| 174 |
-
)
|
| 175 |
-
software_heritage_snapshot = (
|
| 176 |
-
f"https://archive.softwareheritage.org/api/1/snapshot/{snapshot_id}/"
|
| 177 |
-
)
|
| 178 |
-
software_heritage_release = (
|
| 179 |
-
f"https://archive.softwareheritage.org/api/1/release/{release_id}/"
|
| 180 |
-
)
|
| 181 |
-
transport = FakeTransport(
|
| 182 |
-
json_values={
|
| 183 |
-
"https://api.github.com/repos/Lifted-Holdings/payment-processing-resources/releases/tags/v1.1.3": github,
|
| 184 |
-
"https://zenodo.org/api/records/99999999": zenodo,
|
| 185 |
-
"https://huggingface.co/api/datasets/Liftedholdings/payment-statement-audit-model": huggingface,
|
| 186 |
-
software_heritage_visit: {
|
| 187 |
-
"origin": SOURCE_REPOSITORY,
|
| 188 |
-
"status": "full",
|
| 189 |
-
"snapshot": snapshot_id,
|
| 190 |
-
},
|
| 191 |
-
software_heritage_snapshot: {
|
| 192 |
-
"id": snapshot_id,
|
| 193 |
-
"branches": {
|
| 194 |
-
"refs/heads/main": {
|
| 195 |
-
"target": expected_commit,
|
| 196 |
-
"target_type": "revision",
|
| 197 |
-
},
|
| 198 |
-
"refs/tags/v1.1.3": {
|
| 199 |
-
"target": release_id,
|
| 200 |
-
"target_type": "release",
|
| 201 |
-
},
|
| 202 |
-
},
|
| 203 |
-
},
|
| 204 |
-
software_heritage_release: {
|
| 205 |
-
"id": release_id,
|
| 206 |
-
"name": "v1.1.3",
|
| 207 |
-
"target": expected_commit,
|
| 208 |
-
"target_type": "revision",
|
| 209 |
-
},
|
| 210 |
-
},
|
| 211 |
-
byte_values={
|
| 212 |
-
github_zip: archive,
|
| 213 |
-
github_sidecar: sidecar,
|
| 214 |
-
zenodo_zip: archive,
|
| 215 |
-
zenodo_sidecar: sidecar,
|
| 216 |
-
huggingface_zip: archive,
|
| 217 |
-
},
|
| 218 |
-
final_urls={
|
| 219 |
-
"https://doi.org/10.5281/zenodo.99999999": "https://zenodo.org/records/99999999"
|
| 220 |
-
},
|
| 221 |
-
)
|
| 222 |
-
return transport, digest, expected_commit, snapshot_id
|
| 223 |
-
|
| 224 |
-
def test_matching_github_zenodo_doi_and_huggingface_artifacts_verify(self):
|
| 225 |
-
transport, digest, expected_commit, snapshot_id = self.make_transport()
|
| 226 |
-
|
| 227 |
-
result = self.attestation.attest_public_release(
|
| 228 |
-
self.root,
|
| 229 |
-
self.manifest,
|
| 230 |
-
transport=transport,
|
| 231 |
-
expected_commit=expected_commit,
|
| 232 |
-
)
|
| 233 |
-
|
| 234 |
-
self.assertTrue(result.verified, result.failure_codes)
|
| 235 |
-
self.assertEqual((), result.failure_codes)
|
| 236 |
-
self.assertEqual(digest, result.archive_sha256)
|
| 237 |
-
self.assertEqual(snapshot_id, result.software_heritage_snapshot)
|
| 238 |
-
|
| 239 |
-
def test_digest_mismatch_blocks_attestation(self):
|
| 240 |
-
transport, _, expected_commit, _ = self.make_transport()
|
| 241 |
-
github_url = next(
|
| 242 |
-
url for url in transport.byte_values if url.startswith("https://github.com")
|
| 243 |
-
and url.endswith(".zip")
|
| 244 |
-
)
|
| 245 |
-
transport.byte_values[github_url] += b"tampered"
|
| 246 |
-
|
| 247 |
-
result = self.attestation.attest_public_release(
|
| 248 |
-
self.root,
|
| 249 |
-
self.manifest,
|
| 250 |
-
transport=transport,
|
| 251 |
-
expected_commit=expected_commit,
|
| 252 |
-
)
|
| 253 |
-
|
| 254 |
-
self.assertFalse(result.verified)
|
| 255 |
-
self.assertIn("github_archive_digest_mismatch", result.failure_codes)
|
| 256 |
-
|
| 257 |
-
def test_zip_traversal_and_duplicate_aliases_are_rejected(self):
|
| 258 |
-
cases = {
|
| 259 |
-
"traversal": {
|
| 260 |
-
"README.md": b"verified release\n",
|
| 261 |
-
"../outside.txt": b"outside",
|
| 262 |
-
},
|
| 263 |
-
"case_alias": {
|
| 264 |
-
"README.md": b"verified release\n",
|
| 265 |
-
"readme.md": b"alias",
|
| 266 |
-
},
|
| 267 |
-
}
|
| 268 |
-
for name, members in cases.items():
|
| 269 |
-
with self.subTest(name=name):
|
| 270 |
-
archive = self.make_zip(members)
|
| 271 |
-
transport, _, expected_commit, _ = self.make_transport(archive)
|
| 272 |
-
result = self.attestation.attest_public_release(
|
| 273 |
-
self.root,
|
| 274 |
-
self.manifest,
|
| 275 |
-
transport=transport,
|
| 276 |
-
expected_commit=expected_commit,
|
| 277 |
-
)
|
| 278 |
-
self.assertFalse(result.verified)
|
| 279 |
-
self.assertIn("release_archive_invalid", result.failure_codes)
|
| 280 |
-
|
| 281 |
-
def test_http_transport_rejects_untrusted_or_insecure_hosts_before_request(self):
|
| 282 |
-
transport = self.attestation.HttpTransport()
|
| 283 |
-
for url in (
|
| 284 |
-
"http://github.com/Lifted-Holdings/example",
|
| 285 |
-
"https://github.com.evil.invalid/payload",
|
| 286 |
-
"https://evil.invalid/payload",
|
| 287 |
-
):
|
| 288 |
-
with self.subTest(url=url):
|
| 289 |
-
with self.assertRaises(ValueError):
|
| 290 |
-
transport.get_bytes(url, max_bytes=1024)
|
| 291 |
-
|
| 292 |
-
def test_doi_resolution_requests_the_human_html_landing_page(self):
|
| 293 |
-
observed = {}
|
| 294 |
-
|
| 295 |
-
class Response:
|
| 296 |
-
headers = {}
|
| 297 |
-
|
| 298 |
-
def __enter__(self):
|
| 299 |
-
return self
|
| 300 |
-
|
| 301 |
-
def __exit__(self, exc_type, exc, traceback):
|
| 302 |
-
return False
|
| 303 |
-
|
| 304 |
-
def geturl(self):
|
| 305 |
-
return "https://zenodo.org/records/99999999"
|
| 306 |
-
|
| 307 |
-
def read(self, size):
|
| 308 |
-
del size
|
| 309 |
-
return b""
|
| 310 |
-
|
| 311 |
-
class Opener:
|
| 312 |
-
def open(self, request, timeout):
|
| 313 |
-
del timeout
|
| 314 |
-
observed["accept"] = request.headers["Accept"]
|
| 315 |
-
return Response()
|
| 316 |
-
|
| 317 |
-
transport = self.attestation.HttpTransport()
|
| 318 |
-
transport._opener = Opener()
|
| 319 |
-
|
| 320 |
-
resolved = transport.resolve(
|
| 321 |
-
"https://doi.org/10.5281/zenodo.99999999", max_bytes=1024
|
| 322 |
-
)
|
| 323 |
-
|
| 324 |
-
self.assertEqual("https://zenodo.org/records/99999999", resolved)
|
| 325 |
-
self.assertEqual("text/html, application/xhtml+xml", observed["accept"])
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
if __name__ == "__main__":
|
| 329 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_publication_gate.py
DELETED
|
@@ -1,574 +0,0 @@
|
|
| 1 |
-
import importlib.util
|
| 2 |
-
import json
|
| 3 |
-
import os
|
| 4 |
-
import shutil
|
| 5 |
-
import subprocess
|
| 6 |
-
import sys
|
| 7 |
-
import tempfile
|
| 8 |
-
import unittest
|
| 9 |
-
from pathlib import Path
|
| 10 |
-
from types import SimpleNamespace
|
| 11 |
-
from unittest import mock
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 15 |
-
GATE_PATH = ROOT / "tools/publication_gate.py"
|
| 16 |
-
MANIFEST_PATH = ROOT / "RELEASE-MANIFEST.json"
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
def load_module(path: Path, name: str):
|
| 20 |
-
spec = importlib.util.spec_from_file_location(name, path)
|
| 21 |
-
if spec is None or spec.loader is None:
|
| 22 |
-
raise RuntimeError(f"Unable to load {name}")
|
| 23 |
-
module = importlib.util.module_from_spec(spec)
|
| 24 |
-
sys.modules[spec.name] = module
|
| 25 |
-
spec.loader.exec_module(module)
|
| 26 |
-
return module
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
class PublicationGateTests(unittest.TestCase):
|
| 30 |
-
@classmethod
|
| 31 |
-
def setUpClass(cls):
|
| 32 |
-
if not GATE_PATH.is_file():
|
| 33 |
-
raise AssertionError("tools/publication_gate.py is required")
|
| 34 |
-
cls.gate = load_module(GATE_PATH, "publication_gate")
|
| 35 |
-
|
| 36 |
-
def test_release_manifest_has_one_explicit_versioned_identity(self):
|
| 37 |
-
manifest = json.loads(MANIFEST_PATH.read_text(encoding="utf-8"))
|
| 38 |
-
self.assertEqual("1.1.3", manifest["version"])
|
| 39 |
-
self.assertEqual("1.1.0", manifest["schema_version"])
|
| 40 |
-
self.assertEqual(
|
| 41 |
-
"10.5281/zenodo.21761714", manifest["concept_doi"]
|
| 42 |
-
)
|
| 43 |
-
self.assertEqual(
|
| 44 |
-
"https://liftedpayments.com/payment-processing-statement-audit/",
|
| 45 |
-
manifest["canonical_url"],
|
| 46 |
-
)
|
| 47 |
-
self.assertTrue(manifest["source_release"].endswith("/releases/tag/v1.1.3"))
|
| 48 |
-
self.assertEqual(len(manifest["files"]), len(set(manifest["files"])))
|
| 49 |
-
self.assertGreaterEqual(len(manifest["files"]), 20)
|
| 50 |
-
|
| 51 |
-
def test_gate_is_fail_closed_until_every_release_condition_is_satisfied(self):
|
| 52 |
-
report = self.gate.build_publication_report(ROOT)
|
| 53 |
-
self.assertIn(report["status"], {"blocked", "valid", "ready", "verified"})
|
| 54 |
-
self.assertEqual("candidate", report["mode"])
|
| 55 |
-
self.assertEqual(report["check_count"], len(report["checks"]))
|
| 56 |
-
self.assertEqual(
|
| 57 |
-
report["failed_check_count"],
|
| 58 |
-
sum(check["status"] == "fail" for check in report["checks"]),
|
| 59 |
-
)
|
| 60 |
-
self.assertIn("corpus_validation", {check["code"] for check in report["checks"]})
|
| 61 |
-
self.assertIn("dependency_lock", {check["code"] for check in report["checks"]})
|
| 62 |
-
self.assertIn("utf8_text_assets", {check["code"] for check in report["checks"]})
|
| 63 |
-
self.assertIn(
|
| 64 |
-
"repository_provenance", {check["code"] for check in report["checks"]}
|
| 65 |
-
)
|
| 66 |
-
manifest = json.loads(MANIFEST_PATH.read_text(encoding="utf-8"))
|
| 67 |
-
if manifest["version_doi"] is None:
|
| 68 |
-
self.assertEqual("blocked", report["status"])
|
| 69 |
-
self.assertIn(
|
| 70 |
-
"version_doi_declared",
|
| 71 |
-
{check["code"] for check in report["checks"] if check["status"] == "fail"},
|
| 72 |
-
)
|
| 73 |
-
|
| 74 |
-
def test_tagless_tree_is_blocked_in_default_candidate_mode(self):
|
| 75 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 76 |
-
candidate = Path(directory) / "release"
|
| 77 |
-
shutil.copytree(ROOT, candidate, ignore=shutil.ignore_patterns(".git"))
|
| 78 |
-
|
| 79 |
-
report = self.gate.build_publication_report(candidate)
|
| 80 |
-
|
| 81 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 82 |
-
self.assertEqual("candidate", report["mode"])
|
| 83 |
-
self.assertEqual("blocked", report["status"])
|
| 84 |
-
self.assertEqual("fail", checks["repository_provenance"])
|
| 85 |
-
|
| 86 |
-
def test_tagless_tree_can_be_package_valid_but_never_publication_ready(self):
|
| 87 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 88 |
-
candidate = Path(directory) / "release"
|
| 89 |
-
shutil.copytree(ROOT, candidate, ignore=shutil.ignore_patterns(".git"))
|
| 90 |
-
|
| 91 |
-
report = self.gate.build_publication_report(candidate, mode="package")
|
| 92 |
-
|
| 93 |
-
self.assertEqual("package", report["mode"])
|
| 94 |
-
self.assertEqual("valid", report["status"])
|
| 95 |
-
self.assertNotIn(
|
| 96 |
-
"repository_provenance", {check["code"] for check in report["checks"]}
|
| 97 |
-
)
|
| 98 |
-
|
| 99 |
-
def test_provenance_failure_prevents_candidate_validator_execution(self):
|
| 100 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 101 |
-
candidate = Path(directory) / "release"
|
| 102 |
-
shutil.copytree(ROOT, candidate, ignore=shutil.ignore_patterns(".git"))
|
| 103 |
-
validator = candidate / "tools/validate_audit.py"
|
| 104 |
-
validator.write_text(
|
| 105 |
-
"from pathlib import Path\n"
|
| 106 |
-
"Path('candidate-validator-executed.marker').write_text('executed')\n"
|
| 107 |
-
"raise SystemExit(1)\n",
|
| 108 |
-
encoding="utf-8",
|
| 109 |
-
)
|
| 110 |
-
subprocess.run(
|
| 111 |
-
[sys.executable, "tools/update_checksums.py", "--write"],
|
| 112 |
-
cwd=candidate,
|
| 113 |
-
check=True,
|
| 114 |
-
capture_output=True,
|
| 115 |
-
text=True,
|
| 116 |
-
encoding="utf-8",
|
| 117 |
-
)
|
| 118 |
-
|
| 119 |
-
report = self.gate.build_publication_report(candidate)
|
| 120 |
-
|
| 121 |
-
self.assertEqual("blocked", report["status"])
|
| 122 |
-
self.assertFalse((candidate / "candidate-validator-executed.marker").exists())
|
| 123 |
-
|
| 124 |
-
def test_cli_package_mode_uses_package_validity_language(self):
|
| 125 |
-
result = subprocess.run(
|
| 126 |
-
[sys.executable, str(GATE_PATH), "--mode", "package", "--json"],
|
| 127 |
-
cwd=ROOT,
|
| 128 |
-
capture_output=True,
|
| 129 |
-
text=True,
|
| 130 |
-
encoding="utf-8",
|
| 131 |
-
)
|
| 132 |
-
report = json.loads(result.stdout)
|
| 133 |
-
self.assertEqual("package", report["mode"])
|
| 134 |
-
self.assertEqual("valid", report["status"])
|
| 135 |
-
self.assertEqual(0, result.returncode)
|
| 136 |
-
|
| 137 |
-
def test_published_mode_requires_and_reports_external_attestation(self):
|
| 138 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 139 |
-
candidate = Path(directory) / "release"
|
| 140 |
-
shutil.copytree(ROOT, candidate, ignore=shutil.ignore_patterns(".git"))
|
| 141 |
-
with mock.patch.object(
|
| 142 |
-
self.gate,
|
| 143 |
-
"inspect_repository",
|
| 144 |
-
return_value=SimpleNamespace(
|
| 145 |
-
publication_ready=True, head_commit="a" * 40
|
| 146 |
-
),
|
| 147 |
-
), mock.patch.object(
|
| 148 |
-
self.gate,
|
| 149 |
-
"attest_public_release",
|
| 150 |
-
return_value=SimpleNamespace(verified=True),
|
| 151 |
-
) as attestor:
|
| 152 |
-
report = self.gate.build_publication_report(candidate, mode="published")
|
| 153 |
-
|
| 154 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 155 |
-
self.assertEqual("verified", report["status"])
|
| 156 |
-
self.assertEqual("pass", checks["public_release_attestation"])
|
| 157 |
-
attestor.assert_called_once()
|
| 158 |
-
|
| 159 |
-
def test_published_mode_blocks_when_external_attestation_disagrees(self):
|
| 160 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 161 |
-
candidate = Path(directory) / "release"
|
| 162 |
-
shutil.copytree(ROOT, candidate, ignore=shutil.ignore_patterns(".git"))
|
| 163 |
-
with mock.patch.object(
|
| 164 |
-
self.gate,
|
| 165 |
-
"inspect_repository",
|
| 166 |
-
return_value=SimpleNamespace(
|
| 167 |
-
publication_ready=True, head_commit="a" * 40
|
| 168 |
-
),
|
| 169 |
-
), mock.patch.object(
|
| 170 |
-
self.gate,
|
| 171 |
-
"attest_public_release",
|
| 172 |
-
return_value=SimpleNamespace(verified=False),
|
| 173 |
-
):
|
| 174 |
-
report = self.gate.build_publication_report(candidate, mode="published")
|
| 175 |
-
|
| 176 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 177 |
-
self.assertEqual("blocked", report["status"])
|
| 178 |
-
self.assertEqual("fail", checks["public_release_attestation"])
|
| 179 |
-
|
| 180 |
-
def test_gate_report_contains_hashes_and_no_file_contents(self):
|
| 181 |
-
report = self.gate.build_publication_report(ROOT)
|
| 182 |
-
rendered = json.dumps(report, sort_keys=True)
|
| 183 |
-
self.assertIn("manifest_sha256", report)
|
| 184 |
-
self.assertRegex(report["manifest_sha256"], r"^[0-9a-f]{64}$")
|
| 185 |
-
self.assertNotIn("4111 1111", rendered)
|
| 186 |
-
self.assertNotIn("CVV 123", rendered)
|
| 187 |
-
for check in report["checks"]:
|
| 188 |
-
self.assertEqual(
|
| 189 |
-
{"code", "status", "message"}, set(check), "gate checks must stay value-free"
|
| 190 |
-
)
|
| 191 |
-
|
| 192 |
-
def test_cli_exit_code_matches_release_readiness(self):
|
| 193 |
-
result = subprocess.run(
|
| 194 |
-
[sys.executable, str(GATE_PATH), "--json"],
|
| 195 |
-
cwd=ROOT,
|
| 196 |
-
capture_output=True,
|
| 197 |
-
text=True,
|
| 198 |
-
encoding="utf-8",
|
| 199 |
-
)
|
| 200 |
-
report = json.loads(result.stdout)
|
| 201 |
-
expected = 0 if report["status"] == "ready" else 1
|
| 202 |
-
self.assertEqual(expected, result.returncode)
|
| 203 |
-
|
| 204 |
-
def test_checksum_tool_verifies_the_exact_manifest_without_rewriting(self):
|
| 205 |
-
result = subprocess.run(
|
| 206 |
-
[sys.executable, "tools/update_checksums.py", "--check"],
|
| 207 |
-
cwd=ROOT,
|
| 208 |
-
capture_output=True,
|
| 209 |
-
text=True,
|
| 210 |
-
encoding="utf-8",
|
| 211 |
-
)
|
| 212 |
-
self.assertEqual(0, result.returncode, result.stdout + result.stderr)
|
| 213 |
-
self.assertEqual("checksums.txt is current\n", result.stdout)
|
| 214 |
-
|
| 215 |
-
def test_gate_scans_every_declared_asset_for_common_secret_signatures(self):
|
| 216 |
-
signatures = (
|
| 217 |
-
"AKIA" + "IOSFODNN7EXAMPLE",
|
| 218 |
-
"sk-proj-" + ("A" * 32),
|
| 219 |
-
"sk-ant-" + ("B" * 32),
|
| 220 |
-
"ya29." + ("C" * 32),
|
| 221 |
-
)
|
| 222 |
-
for signature in signatures:
|
| 223 |
-
with self.subTest(prefix=signature[:7]):
|
| 224 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 225 |
-
candidate = Path(directory) / "release"
|
| 226 |
-
shutil.copytree(ROOT, candidate)
|
| 227 |
-
with (candidate / "LICENSE.md").open(
|
| 228 |
-
"a", encoding="utf-8"
|
| 229 |
-
) as handle:
|
| 230 |
-
handle.write("\n" + signature + "\n")
|
| 231 |
-
|
| 232 |
-
report = self.gate.build_publication_report(candidate)
|
| 233 |
-
checks = {
|
| 234 |
-
check["code"]: check["status"] for check in report["checks"]
|
| 235 |
-
}
|
| 236 |
-
self.assertEqual("fail", checks["public_content_safety"])
|
| 237 |
-
self.assertEqual("blocked", report["status"])
|
| 238 |
-
|
| 239 |
-
def test_gate_executes_the_validator_from_the_candidate_release(self):
|
| 240 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 241 |
-
candidate = Path(directory) / "release"
|
| 242 |
-
shutil.copytree(ROOT, candidate)
|
| 243 |
-
(candidate / "tools/validate_audit.py").write_text(
|
| 244 |
-
'raise RuntimeError("tampered validator")\n', encoding="utf-8"
|
| 245 |
-
)
|
| 246 |
-
|
| 247 |
-
report = self.gate.build_publication_report(candidate)
|
| 248 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 249 |
-
self.assertEqual("fail", checks["corpus_validation"])
|
| 250 |
-
self.assertEqual("blocked", report["status"])
|
| 251 |
-
|
| 252 |
-
def test_gate_requires_every_security_critical_release_asset(self):
|
| 253 |
-
critical_assets = (
|
| 254 |
-
"tools/public_release_attestation.py",
|
| 255 |
-
"tools/publication_gate.py",
|
| 256 |
-
"tools/release_provenance.py",
|
| 257 |
-
"tests/test_public_release_attestation.py",
|
| 258 |
-
"tests/test_release_provenance.py",
|
| 259 |
-
)
|
| 260 |
-
for critical_asset in critical_assets:
|
| 261 |
-
with self.subTest(critical_asset=critical_asset):
|
| 262 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 263 |
-
candidate = Path(directory) / "release"
|
| 264 |
-
shutil.copytree(ROOT, candidate)
|
| 265 |
-
manifest_path = candidate / "RELEASE-MANIFEST.json"
|
| 266 |
-
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
| 267 |
-
manifest["files"].remove(critical_asset)
|
| 268 |
-
manifest_path.write_text(
|
| 269 |
-
json.dumps(manifest, indent=2) + "\n", encoding="utf-8"
|
| 270 |
-
)
|
| 271 |
-
|
| 272 |
-
report = self.gate.build_publication_report(candidate)
|
| 273 |
-
checks = {
|
| 274 |
-
check["code"]: check["status"] for check in report["checks"]
|
| 275 |
-
}
|
| 276 |
-
self.assertEqual("fail", checks["required_release_assets"])
|
| 277 |
-
self.assertEqual("blocked", report["status"])
|
| 278 |
-
|
| 279 |
-
def test_gate_blocks_an_undeclared_regular_file_in_the_release_tree(self):
|
| 280 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 281 |
-
candidate = Path(directory) / "release"
|
| 282 |
-
shutil.copytree(ROOT, candidate)
|
| 283 |
-
(candidate / "undeclared-public-payload.txt").write_text(
|
| 284 |
-
"This file is not covered by the manifest or checksums.\n",
|
| 285 |
-
encoding="utf-8",
|
| 286 |
-
)
|
| 287 |
-
|
| 288 |
-
report = self.gate.build_publication_report(candidate)
|
| 289 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 290 |
-
self.assertEqual("fail", checks["manifest_inventory"])
|
| 291 |
-
self.assertEqual("blocked", report["status"])
|
| 292 |
-
|
| 293 |
-
def test_gate_blocks_an_oversized_declared_text_asset(self):
|
| 294 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 295 |
-
candidate = Path(directory) / "release"
|
| 296 |
-
shutil.copytree(ROOT, candidate)
|
| 297 |
-
oversized_name = "oversized-public-payload.txt"
|
| 298 |
-
(candidate / oversized_name).write_bytes(b"x" * (5 * 1024 * 1024 + 1))
|
| 299 |
-
manifest_path = candidate / "RELEASE-MANIFEST.json"
|
| 300 |
-
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
| 301 |
-
manifest["files"].append(oversized_name)
|
| 302 |
-
manifest_path.write_text(
|
| 303 |
-
json.dumps(manifest, indent=2) + "\n", encoding="utf-8"
|
| 304 |
-
)
|
| 305 |
-
subprocess.run(
|
| 306 |
-
[sys.executable, "tools/update_checksums.py", "--write"],
|
| 307 |
-
cwd=candidate,
|
| 308 |
-
check=True,
|
| 309 |
-
capture_output=True,
|
| 310 |
-
text=True,
|
| 311 |
-
encoding="utf-8",
|
| 312 |
-
)
|
| 313 |
-
|
| 314 |
-
report = self.gate.build_publication_report(candidate)
|
| 315 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 316 |
-
self.assertEqual("fail", checks["release_size_limits"])
|
| 317 |
-
self.assertEqual("blocked", report["status"])
|
| 318 |
-
|
| 319 |
-
def test_gate_runs_the_candidate_validator_regression_suite(self):
|
| 320 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 321 |
-
candidate = Path(directory) / "release"
|
| 322 |
-
shutil.copytree(ROOT, candidate)
|
| 323 |
-
validator_path = candidate / "tools/validate_audit.py"
|
| 324 |
-
validator = validator_path.read_text(encoding="utf-8")
|
| 325 |
-
validator = validator.replace(
|
| 326 |
-
'_EMAIL = re.compile(r"\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b", re.I)',
|
| 327 |
-
'_EMAIL = re.compile(r"$^")',
|
| 328 |
-
)
|
| 329 |
-
self.assertIn('_EMAIL = re.compile(r"$^")', validator)
|
| 330 |
-
validator_path.write_text(validator, encoding="utf-8")
|
| 331 |
-
|
| 332 |
-
corpus = subprocess.run(
|
| 333 |
-
[sys.executable, "tools/validate_audit.py", "--corpus"],
|
| 334 |
-
cwd=candidate,
|
| 335 |
-
check=True,
|
| 336 |
-
capture_output=True,
|
| 337 |
-
text=True,
|
| 338 |
-
encoding="utf-8",
|
| 339 |
-
)
|
| 340 |
-
(candidate / "validation-report.json").write_text(
|
| 341 |
-
corpus.stdout, encoding="utf-8"
|
| 342 |
-
)
|
| 343 |
-
subprocess.run(
|
| 344 |
-
[sys.executable, "tools/update_checksums.py", "--write"],
|
| 345 |
-
cwd=candidate,
|
| 346 |
-
check=True,
|
| 347 |
-
capture_output=True,
|
| 348 |
-
text=True,
|
| 349 |
-
encoding="utf-8",
|
| 350 |
-
)
|
| 351 |
-
|
| 352 |
-
report = self.gate.build_publication_report(candidate)
|
| 353 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 354 |
-
self.assertEqual("fail", checks["candidate_regression_suite"])
|
| 355 |
-
self.assertEqual("blocked", report["status"])
|
| 356 |
-
|
| 357 |
-
def test_gate_rejects_untrusted_manifest_identity_even_when_metadata_agrees(self):
|
| 358 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 359 |
-
candidate = Path(directory) / "release"
|
| 360 |
-
shutil.copytree(ROOT, candidate)
|
| 361 |
-
manifest_path = candidate / "RELEASE-MANIFEST.json"
|
| 362 |
-
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
| 363 |
-
old_concept_doi = manifest["concept_doi"]
|
| 364 |
-
manifest["concept_doi"] = "not-a-doi"
|
| 365 |
-
manifest_path.write_text(
|
| 366 |
-
json.dumps(manifest, indent=2) + "\n", encoding="utf-8"
|
| 367 |
-
)
|
| 368 |
-
|
| 369 |
-
codemeta_path = candidate / "codemeta.json"
|
| 370 |
-
codemeta = json.loads(codemeta_path.read_text(encoding="utf-8"))
|
| 371 |
-
codemeta["sameAs"] = [
|
| 372 |
-
value.replace(
|
| 373 |
-
f"https://doi.org/{old_concept_doi}",
|
| 374 |
-
"https://doi.org/not-a-doi",
|
| 375 |
-
)
|
| 376 |
-
for value in codemeta["sameAs"]
|
| 377 |
-
]
|
| 378 |
-
codemeta_path.write_text(
|
| 379 |
-
json.dumps(codemeta, indent=2) + "\n", encoding="utf-8"
|
| 380 |
-
)
|
| 381 |
-
subprocess.run(
|
| 382 |
-
[sys.executable, "tools/update_checksums.py", "--write"],
|
| 383 |
-
cwd=candidate,
|
| 384 |
-
check=True,
|
| 385 |
-
capture_output=True,
|
| 386 |
-
text=True,
|
| 387 |
-
encoding="utf-8",
|
| 388 |
-
)
|
| 389 |
-
|
| 390 |
-
report = self.gate.build_publication_report(candidate)
|
| 391 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 392 |
-
self.assertEqual("fail", checks["manifest_identity"])
|
| 393 |
-
self.assertEqual("blocked", report["status"])
|
| 394 |
-
|
| 395 |
-
def test_gate_blocks_changes_masquerading_as_an_existing_release_tag(self):
|
| 396 |
-
tag_check = subprocess.run(
|
| 397 |
-
["git", "rev-parse", "--verify", "refs/tags/v1.1.1"],
|
| 398 |
-
cwd=ROOT,
|
| 399 |
-
capture_output=True,
|
| 400 |
-
text=True,
|
| 401 |
-
encoding="utf-8",
|
| 402 |
-
)
|
| 403 |
-
if tag_check.returncode != 0:
|
| 404 |
-
self.skipTest("v1.1.1 tag is required for the immutability regression")
|
| 405 |
-
|
| 406 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 407 |
-
candidate = Path(directory) / "release"
|
| 408 |
-
shutil.copytree(ROOT, candidate)
|
| 409 |
-
with (candidate / "README.md").open("a", encoding="utf-8") as handle:
|
| 410 |
-
handle.write("\nUndisclosed rewrite of an immutable release.\n")
|
| 411 |
-
subprocess.run(
|
| 412 |
-
[sys.executable, "tools/update_checksums.py", "--write"],
|
| 413 |
-
cwd=candidate,
|
| 414 |
-
check=True,
|
| 415 |
-
capture_output=True,
|
| 416 |
-
text=True,
|
| 417 |
-
encoding="utf-8",
|
| 418 |
-
)
|
| 419 |
-
|
| 420 |
-
manifest = json.loads(
|
| 421 |
-
(candidate / "RELEASE-MANIFEST.json").read_text(encoding="utf-8")
|
| 422 |
-
)
|
| 423 |
-
manifest["version"] = "1.1.1"
|
| 424 |
-
self.assertFalse(
|
| 425 |
-
self.gate._matches_existing_release_tag(
|
| 426 |
-
candidate, manifest, manifest["files"]
|
| 427 |
-
)
|
| 428 |
-
)
|
| 429 |
-
|
| 430 |
-
def test_gate_returns_a_structured_block_for_a_malformed_manifest(self):
|
| 431 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 432 |
-
candidate = Path(directory) / "release"
|
| 433 |
-
shutil.copytree(ROOT, candidate)
|
| 434 |
-
(candidate / "RELEASE-MANIFEST.json").write_text(
|
| 435 |
-
"{not-json", encoding="utf-8"
|
| 436 |
-
)
|
| 437 |
-
|
| 438 |
-
report = self.gate.build_publication_report(candidate)
|
| 439 |
-
self.assertEqual("blocked", report["status"])
|
| 440 |
-
self.assertEqual("manifest_read", report["checks"][0]["code"])
|
| 441 |
-
self.assertEqual("fail", report["checks"][0]["status"])
|
| 442 |
-
|
| 443 |
-
def test_manifest_traversal_is_blocked_without_reading_outside_release(self):
|
| 444 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 445 |
-
parent = Path(directory)
|
| 446 |
-
candidate = parent / "release"
|
| 447 |
-
shutil.copytree(ROOT, candidate)
|
| 448 |
-
(parent / "outside.txt").write_text(
|
| 449 |
-
"AKIA" + "IOSFODNN7EXAMPLE", encoding="utf-8"
|
| 450 |
-
)
|
| 451 |
-
manifest_path = candidate / "RELEASE-MANIFEST.json"
|
| 452 |
-
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
| 453 |
-
manifest["files"].append("../outside.txt")
|
| 454 |
-
manifest_path.write_text(
|
| 455 |
-
json.dumps(manifest, indent=2) + "\n", encoding="utf-8"
|
| 456 |
-
)
|
| 457 |
-
|
| 458 |
-
paths, safe = self.gate._safe_file_paths(candidate, manifest["files"])
|
| 459 |
-
self.assertFalse(safe)
|
| 460 |
-
self.assertNotIn((parent / "outside.txt").resolve(), paths)
|
| 461 |
-
report = self.gate.build_publication_report(candidate)
|
| 462 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 463 |
-
self.assertEqual("blocked", report["status"])
|
| 464 |
-
self.assertEqual("fail", checks["manifest_inventory"])
|
| 465 |
-
self.assertEqual("fail", checks["public_content_safety"])
|
| 466 |
-
|
| 467 |
-
def test_manifest_rejects_noncanonical_aliases_of_the_same_file(self):
|
| 468 |
-
paths, safe = self.gate._safe_file_paths(
|
| 469 |
-
ROOT, ["README.md", "./README.md"]
|
| 470 |
-
)
|
| 471 |
-
self.assertFalse(safe)
|
| 472 |
-
self.assertEqual([ROOT / "README.md"], paths)
|
| 473 |
-
|
| 474 |
-
def test_gate_blocks_a_missing_identity_asset_without_throwing(self):
|
| 475 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 476 |
-
candidate = Path(directory) / "release"
|
| 477 |
-
shutil.copytree(ROOT, candidate)
|
| 478 |
-
(candidate / "README.md").unlink()
|
| 479 |
-
|
| 480 |
-
report = self.gate.build_publication_report(candidate)
|
| 481 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 482 |
-
self.assertEqual("blocked", report["status"])
|
| 483 |
-
self.assertEqual("fail", checks["manifest_inventory"])
|
| 484 |
-
self.assertEqual("fail", checks["release_identity"])
|
| 485 |
-
|
| 486 |
-
def test_gate_blocks_non_utf8_integrity_metadata_without_throwing(self):
|
| 487 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 488 |
-
candidate = Path(directory) / "release"
|
| 489 |
-
shutil.copytree(ROOT, candidate)
|
| 490 |
-
(candidate / "checksums.txt").write_bytes(b"\xff\xfe\x00")
|
| 491 |
-
|
| 492 |
-
report = self.gate.build_publication_report(candidate)
|
| 493 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 494 |
-
self.assertEqual("blocked", report["status"])
|
| 495 |
-
self.assertEqual("fail", checks["release_checksums"])
|
| 496 |
-
self.assertEqual("fail", checks["utf8_text_assets"])
|
| 497 |
-
|
| 498 |
-
def test_gate_rejects_an_artifact_beneath_a_symlinked_directory(self):
|
| 499 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 500 |
-
parent = Path(directory)
|
| 501 |
-
candidate = parent / "release"
|
| 502 |
-
shutil.copytree(ROOT, candidate)
|
| 503 |
-
target = candidate / "real-assets"
|
| 504 |
-
target.mkdir()
|
| 505 |
-
(target / "nested.txt").write_text("safe", encoding="utf-8")
|
| 506 |
-
alias = candidate / "alias"
|
| 507 |
-
try:
|
| 508 |
-
os.symlink(target, alias, target_is_directory=True)
|
| 509 |
-
except OSError as exc:
|
| 510 |
-
self.skipTest(f"directory symlinks unavailable: {exc}")
|
| 511 |
-
|
| 512 |
-
paths, safe = self.gate._safe_file_paths(
|
| 513 |
-
candidate, ["alias/nested.txt"]
|
| 514 |
-
)
|
| 515 |
-
self.assertFalse(safe)
|
| 516 |
-
self.assertEqual([], paths)
|
| 517 |
-
|
| 518 |
-
def test_release_identity_includes_publication_date(self):
|
| 519 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 520 |
-
candidate = Path(directory) / "release"
|
| 521 |
-
shutil.copytree(ROOT, candidate)
|
| 522 |
-
metadata_path = candidate / ".zenodo.json"
|
| 523 |
-
metadata = json.loads(metadata_path.read_text(encoding="utf-8"))
|
| 524 |
-
metadata["publication_date"] = "1900-01-01"
|
| 525 |
-
metadata_path.write_text(
|
| 526 |
-
json.dumps(metadata, indent=2) + "\n", encoding="utf-8"
|
| 527 |
-
)
|
| 528 |
-
subprocess.run(
|
| 529 |
-
[sys.executable, "tools/update_checksums.py", "--write"],
|
| 530 |
-
cwd=candidate,
|
| 531 |
-
check=True,
|
| 532 |
-
capture_output=True,
|
| 533 |
-
text=True,
|
| 534 |
-
encoding="utf-8",
|
| 535 |
-
)
|
| 536 |
-
|
| 537 |
-
report = self.gate.build_publication_report(candidate)
|
| 538 |
-
checks = {check["code"]: check["status"] for check in report["checks"]}
|
| 539 |
-
self.assertEqual("blocked", report["status"])
|
| 540 |
-
self.assertEqual("fail", checks["release_identity"])
|
| 541 |
-
self.assertEqual("pass", checks["release_checksums"])
|
| 542 |
-
|
| 543 |
-
def test_non_object_identity_documents_block_without_throwing(self):
|
| 544 |
-
identity_files = (
|
| 545 |
-
".zenodo.json",
|
| 546 |
-
"codemeta.json",
|
| 547 |
-
"schema/payment-statement-audit.schema.json",
|
| 548 |
-
"examples/payment-statement-audit-example.json",
|
| 549 |
-
)
|
| 550 |
-
for filename in identity_files:
|
| 551 |
-
with self.subTest(filename=filename):
|
| 552 |
-
with tempfile.TemporaryDirectory() as directory:
|
| 553 |
-
candidate = Path(directory) / "release"
|
| 554 |
-
shutil.copytree(ROOT, candidate)
|
| 555 |
-
(candidate / filename).write_text("[]\n", encoding="utf-8")
|
| 556 |
-
subprocess.run(
|
| 557 |
-
[sys.executable, "tools/update_checksums.py", "--write"],
|
| 558 |
-
cwd=candidate,
|
| 559 |
-
check=True,
|
| 560 |
-
capture_output=True,
|
| 561 |
-
text=True,
|
| 562 |
-
encoding="utf-8",
|
| 563 |
-
)
|
| 564 |
-
|
| 565 |
-
report = self.gate.build_publication_report(candidate)
|
| 566 |
-
checks = {
|
| 567 |
-
check["code"]: check["status"] for check in report["checks"]
|
| 568 |
-
}
|
| 569 |
-
self.assertEqual("blocked", report["status"])
|
| 570 |
-
self.assertEqual("fail", checks["release_identity"])
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
if __name__ == "__main__":
|
| 574 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_release_assets.py
DELETED
|
@@ -1,275 +0,0 @@
|
|
| 1 |
-
import hashlib
|
| 2 |
-
import json
|
| 3 |
-
import re
|
| 4 |
-
import subprocess
|
| 5 |
-
import unittest
|
| 6 |
-
from pathlib import Path
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 10 |
-
TITLE = "Lifted Payments Payment Statement Audit Model"
|
| 11 |
-
CANONICAL_URL = "https://liftedpayments.com/payment-processing-statement-audit/"
|
| 12 |
-
REPOSITORY_URL = "https://github.com/Lifted-Holdings/payment-processing-resources"
|
| 13 |
-
VERSION = "1.1.3"
|
| 14 |
-
SCHEMA_VERSION = "1.1.0"
|
| 15 |
-
RELEASE_DATE = "2026-08-02"
|
| 16 |
-
DOI = "10.5281/zenodo.21764642"
|
| 17 |
-
DOI_URL = f"https://doi.org/{DOI}"
|
| 18 |
-
CONCEPT_DOI_URL = "https://doi.org/10.5281/zenodo.21761714"
|
| 19 |
-
RELEASE_URL = (
|
| 20 |
-
"https://github.com/Lifted-Holdings/payment-processing-resources/"
|
| 21 |
-
"releases/tag/v1.1.3"
|
| 22 |
-
)
|
| 23 |
-
HUGGING_FACE_REPO_ID = "Liftedholdings/payment-statement-audit-model"
|
| 24 |
-
KAGGLE_DATASET_ID = "liftedpayments/payment-statement-audit-model"
|
| 25 |
-
RUNTIME_ONLY_DIRECTORIES = {
|
| 26 |
-
".git",
|
| 27 |
-
".mypy_cache",
|
| 28 |
-
".pytest_cache",
|
| 29 |
-
".ruff_cache",
|
| 30 |
-
".venv",
|
| 31 |
-
"__pycache__",
|
| 32 |
-
"venv",
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
def git_metadata_is_available():
|
| 37 |
-
try:
|
| 38 |
-
result = subprocess.run(
|
| 39 |
-
["git", "rev-parse", "--is-inside-work-tree"],
|
| 40 |
-
cwd=ROOT,
|
| 41 |
-
capture_output=True,
|
| 42 |
-
text=True,
|
| 43 |
-
encoding="utf-8",
|
| 44 |
-
)
|
| 45 |
-
except OSError:
|
| 46 |
-
return False
|
| 47 |
-
return result.returncode == 0 and result.stdout.strip() == "true"
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
def portable_release_inventory():
|
| 51 |
-
files = set()
|
| 52 |
-
for path in ROOT.rglob("*"):
|
| 53 |
-
relative = path.relative_to(ROOT)
|
| 54 |
-
if any(part in RUNTIME_ONLY_DIRECTORIES for part in relative.parts):
|
| 55 |
-
continue
|
| 56 |
-
if path.is_file() or path.is_symlink():
|
| 57 |
-
files.add(relative.as_posix())
|
| 58 |
-
return files
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
class ReleaseAssetTests(unittest.TestCase):
|
| 62 |
-
def test_zenodo_metadata_is_complete_and_consistent(self):
|
| 63 |
-
metadata = json.loads((ROOT / ".zenodo.json").read_text(encoding="utf-8"))
|
| 64 |
-
|
| 65 |
-
self.assertEqual(metadata["title"], TITLE)
|
| 66 |
-
self.assertEqual(metadata["version"], VERSION)
|
| 67 |
-
self.assertEqual(metadata["publication_date"], RELEASE_DATE)
|
| 68 |
-
self.assertEqual(metadata["upload_type"], "dataset")
|
| 69 |
-
self.assertEqual(metadata["access_right"], "open")
|
| 70 |
-
self.assertEqual(metadata["license"], "cc-by-4.0")
|
| 71 |
-
self.assertEqual(metadata["language"], "eng")
|
| 72 |
-
self.assertIn(
|
| 73 |
-
{"name": "Lifted Payments", "affiliation": "Lifted Holdings"},
|
| 74 |
-
metadata["creators"],
|
| 75 |
-
)
|
| 76 |
-
self.assertGreaterEqual(len(metadata["keywords"]), 6)
|
| 77 |
-
|
| 78 |
-
manifest = json.loads(
|
| 79 |
-
(ROOT / "RELEASE-MANIFEST.json").read_text(encoding="utf-8")
|
| 80 |
-
)
|
| 81 |
-
self.assertEqual(RELEASE_DATE, manifest["release_date"])
|
| 82 |
-
|
| 83 |
-
related = {
|
| 84 |
-
(item["identifier"], item["relation"])
|
| 85 |
-
for item in metadata["related_identifiers"]
|
| 86 |
-
}
|
| 87 |
-
self.assertIn((CANONICAL_URL, "isDocumentedBy"), related)
|
| 88 |
-
self.assertIn((RELEASE_URL, "isSourceOf"), related)
|
| 89 |
-
|
| 90 |
-
def test_codemeta_describes_the_same_dataset(self):
|
| 91 |
-
metadata = json.loads((ROOT / "codemeta.json").read_text(encoding="utf-8"))
|
| 92 |
-
|
| 93 |
-
self.assertEqual(metadata["@type"], "Dataset")
|
| 94 |
-
self.assertEqual(metadata["name"], TITLE)
|
| 95 |
-
self.assertEqual(metadata["version"], VERSION)
|
| 96 |
-
self.assertEqual(metadata["datePublished"], RELEASE_DATE)
|
| 97 |
-
self.assertEqual(metadata["license"], "https://creativecommons.org/licenses/by/4.0/")
|
| 98 |
-
self.assertEqual(metadata["url"], CANONICAL_URL)
|
| 99 |
-
self.assertEqual(metadata["codeRepository"], REPOSITORY_URL)
|
| 100 |
-
self.assertEqual(metadata["creator"]["name"], "Lifted Payments")
|
| 101 |
-
self.assertEqual(metadata["publisher"]["name"], "Lifted Holdings")
|
| 102 |
-
self.assertTrue(metadata["isAccessibleForFree"])
|
| 103 |
-
self.assertEqual(metadata["identifier"], DOI_URL)
|
| 104 |
-
self.assertIn(DOI_URL, metadata["sameAs"])
|
| 105 |
-
|
| 106 |
-
def test_citation_metadata_matches_release(self):
|
| 107 |
-
citation = (ROOT / "CITATION.cff").read_text(encoding="utf-8")
|
| 108 |
-
|
| 109 |
-
self.assertRegex(citation, rf'(?m)^title: "{re.escape(TITLE)}"$')
|
| 110 |
-
self.assertRegex(citation, rf"(?m)^version: {re.escape(VERSION)}$")
|
| 111 |
-
self.assertRegex(citation, rf"(?m)^date-released: {re.escape(RELEASE_DATE)}$")
|
| 112 |
-
self.assertIn(f'url: "{CANONICAL_URL}"', citation)
|
| 113 |
-
self.assertIn(f'repository-code: "{REPOSITORY_URL}"', citation)
|
| 114 |
-
self.assertRegex(citation, r"(?m)^type: dataset$")
|
| 115 |
-
self.assertRegex(citation, r"(?m)^license: CC-BY-4\.0$")
|
| 116 |
-
self.assertRegex(citation, rf'(?m)^doi: "{re.escape(DOI)}"$')
|
| 117 |
-
|
| 118 |
-
def test_schema_and_synthetic_example_are_internally_consistent(self):
|
| 119 |
-
schema = json.loads(
|
| 120 |
-
(ROOT / "schema/payment-statement-audit.schema.json").read_text(
|
| 121 |
-
encoding="utf-8"
|
| 122 |
-
)
|
| 123 |
-
)
|
| 124 |
-
example = json.loads(
|
| 125 |
-
(ROOT / "examples/payment-statement-audit-example.json").read_text(
|
| 126 |
-
encoding="utf-8"
|
| 127 |
-
)
|
| 128 |
-
)
|
| 129 |
-
|
| 130 |
-
for field in schema["required"]:
|
| 131 |
-
self.assertIn(field, example)
|
| 132 |
-
self.assertEqual(schema["$schema"], "https://json-schema.org/draft/2020-12/schema")
|
| 133 |
-
self.assertAlmostEqual(
|
| 134 |
-
example["effective_rate"],
|
| 135 |
-
example["total_processing_fees"] / example["card_volume"],
|
| 136 |
-
places=6,
|
| 137 |
-
)
|
| 138 |
-
self.assertTrue(
|
| 139 |
-
any("synthetic" in note.lower() for note in example["review_notes"])
|
| 140 |
-
)
|
| 141 |
-
self.assertEqual(SCHEMA_VERSION, example["schema_version"])
|
| 142 |
-
|
| 143 |
-
def test_checksums_cover_every_declared_release_file(self):
|
| 144 |
-
manifest = json.loads(
|
| 145 |
-
(ROOT / "RELEASE-MANIFEST.json").read_text(encoding="utf-8")
|
| 146 |
-
)
|
| 147 |
-
expected_files = set(manifest["files"]) - {"checksums.txt"}
|
| 148 |
-
checksum_lines = (ROOT / "checksums.txt").read_text(encoding="utf-8").splitlines()
|
| 149 |
-
checksums = {}
|
| 150 |
-
for line in checksum_lines:
|
| 151 |
-
digest, filename = re.split(r"\s+", line.strip(), maxsplit=1)
|
| 152 |
-
checksums[filename] = digest
|
| 153 |
-
|
| 154 |
-
self.assertEqual(set(checksums), expected_files)
|
| 155 |
-
for filename, expected_digest in checksums.items():
|
| 156 |
-
actual_digest = hashlib.sha256((ROOT / filename).read_bytes()).hexdigest()
|
| 157 |
-
self.assertEqual(expected_digest, actual_digest)
|
| 158 |
-
|
| 159 |
-
def test_release_manifest_covers_every_repository_asset(self):
|
| 160 |
-
manifest = json.loads(
|
| 161 |
-
(ROOT / "RELEASE-MANIFEST.json").read_text(encoding="utf-8")
|
| 162 |
-
)
|
| 163 |
-
if git_metadata_is_available():
|
| 164 |
-
result = subprocess.run(
|
| 165 |
-
[
|
| 166 |
-
"git",
|
| 167 |
-
"ls-files",
|
| 168 |
-
"--cached",
|
| 169 |
-
"--others",
|
| 170 |
-
"--exclude-standard",
|
| 171 |
-
],
|
| 172 |
-
cwd=ROOT,
|
| 173 |
-
check=True,
|
| 174 |
-
capture_output=True,
|
| 175 |
-
text=True,
|
| 176 |
-
encoding="utf-8",
|
| 177 |
-
)
|
| 178 |
-
repository_files = {
|
| 179 |
-
line.replace("\\", "/")
|
| 180 |
-
for line in result.stdout.splitlines()
|
| 181 |
-
if line
|
| 182 |
-
}
|
| 183 |
-
else:
|
| 184 |
-
repository_files = portable_release_inventory()
|
| 185 |
-
self.assertEqual(repository_files, set(manifest["files"]))
|
| 186 |
-
|
| 187 |
-
def test_release_files_are_pinned_to_lf_by_git(self):
|
| 188 |
-
manifest = json.loads(
|
| 189 |
-
(ROOT / "RELEASE-MANIFEST.json").read_text(encoding="utf-8")
|
| 190 |
-
)
|
| 191 |
-
release_files = manifest["files"]
|
| 192 |
-
if git_metadata_is_available():
|
| 193 |
-
result = subprocess.run(
|
| 194 |
-
["git", "check-attr", "eol", "--", *release_files],
|
| 195 |
-
cwd=ROOT,
|
| 196 |
-
check=True,
|
| 197 |
-
capture_output=True,
|
| 198 |
-
text=True,
|
| 199 |
-
encoding="utf-8",
|
| 200 |
-
)
|
| 201 |
-
|
| 202 |
-
observed = {
|
| 203 |
-
line.split(": ", maxsplit=2)[0]: line.split(": ", maxsplit=2)[2]
|
| 204 |
-
for line in result.stdout.splitlines()
|
| 205 |
-
}
|
| 206 |
-
self.assertEqual(observed, {filename: "lf" for filename in release_files})
|
| 207 |
-
else:
|
| 208 |
-
for filename in release_files:
|
| 209 |
-
with self.subTest(filename=filename):
|
| 210 |
-
self.assertNotIn(b"\r\n", (ROOT / filename).read_bytes())
|
| 211 |
-
|
| 212 |
-
def test_readme_presents_the_versioned_release_and_canonical_citation(self):
|
| 213 |
-
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
| 214 |
-
|
| 215 |
-
self.assertIn("## Versioned release", readme)
|
| 216 |
-
self.assertIn("v1.1.3", readme)
|
| 217 |
-
self.assertIn("August 2, 2026", readme)
|
| 218 |
-
self.assertIn(CANONICAL_URL, readme)
|
| 219 |
-
self.assertIn("CITATION.cff", readme)
|
| 220 |
-
self.assertIn(DOI_URL, readme)
|
| 221 |
-
self.assertNotIn("DOI_PLACEHOLDER", readme)
|
| 222 |
-
|
| 223 |
-
def test_ai_summary_exposes_the_persistent_identifier(self):
|
| 224 |
-
llms = (ROOT / "llms.txt").read_text(encoding="utf-8")
|
| 225 |
-
|
| 226 |
-
self.assertIn(DOI_URL, llms)
|
| 227 |
-
self.assertIn(
|
| 228 |
-
"https://github.com/Lifted-Holdings/payment-processing-resources/releases/tag/v1.1.3",
|
| 229 |
-
llms,
|
| 230 |
-
)
|
| 231 |
-
|
| 232 |
-
def test_huggingface_dataset_card_matches_release_identity(self):
|
| 233 |
-
card_path = ROOT / "distribution/huggingface/README.md"
|
| 234 |
-
self.assertTrue(card_path.is_file(), "Hugging Face dataset card is missing")
|
| 235 |
-
card = card_path.read_text(encoding="utf-8")
|
| 236 |
-
self.assertTrue(card.startswith("---\n"))
|
| 237 |
-
_, frontmatter, body = card.split("---", maxsplit=2)
|
| 238 |
-
|
| 239 |
-
self.assertRegex(frontmatter, r"(?m)^license: cc-by-4\.0$")
|
| 240 |
-
self.assertRegex(
|
| 241 |
-
frontmatter, rf'(?m)^pretty_name: "{re.escape(TITLE)}"$'
|
| 242 |
-
)
|
| 243 |
-
self.assertRegex(frontmatter, r"(?m)^- en$")
|
| 244 |
-
for tag in ("tabular", "finance", "payments", "merchant-services"):
|
| 245 |
-
self.assertRegex(frontmatter, rf"(?m)^- {re.escape(tag)}$")
|
| 246 |
-
|
| 247 |
-
for identity_url in (CANONICAL_URL, DOI_URL, CONCEPT_DOI_URL, RELEASE_URL):
|
| 248 |
-
self.assertIn(identity_url, body)
|
| 249 |
-
self.assertIn(VERSION, body)
|
| 250 |
-
self.assertIn("synthetic", body.lower())
|
| 251 |
-
self.assertIn("no real merchant", body.lower())
|
| 252 |
-
|
| 253 |
-
def test_kaggle_distribution_metadata_matches_release_identity(self):
|
| 254 |
-
metadata_path = ROOT / "distribution/kaggle/dataset-metadata.json"
|
| 255 |
-
description_path = ROOT / "distribution/kaggle/README.md"
|
| 256 |
-
self.assertTrue(metadata_path.is_file(), "Kaggle metadata is missing")
|
| 257 |
-
self.assertTrue(description_path.is_file(), "Kaggle description is missing")
|
| 258 |
-
metadata = json.loads(
|
| 259 |
-
metadata_path.read_text(encoding="utf-8")
|
| 260 |
-
)
|
| 261 |
-
description = description_path.read_text(encoding="utf-8")
|
| 262 |
-
|
| 263 |
-
self.assertEqual(metadata["id"], KAGGLE_DATASET_ID)
|
| 264 |
-
self.assertEqual(metadata["title"], TITLE)
|
| 265 |
-
self.assertIn("merchant statement", metadata["subtitle"].lower())
|
| 266 |
-
self.assertIn({"name": "CC-BY-4.0"}, metadata["licenses"])
|
| 267 |
-
for identity_url in (CANONICAL_URL, DOI_URL, CONCEPT_DOI_URL, RELEASE_URL):
|
| 268 |
-
self.assertIn(identity_url, description)
|
| 269 |
-
self.assertIn(VERSION, description)
|
| 270 |
-
self.assertIn("synthetic", description.lower())
|
| 271 |
-
self.assertIn("no real merchant", description.lower())
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
if __name__ == "__main__":
|
| 275 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_release_provenance.py
DELETED
|
@@ -1,189 +0,0 @@
|
|
| 1 |
-
import importlib.util
|
| 2 |
-
import subprocess
|
| 3 |
-
import sys
|
| 4 |
-
import tempfile
|
| 5 |
-
import unittest
|
| 6 |
-
from pathlib import Path
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
ROOT = Path(__file__).resolve().parents[1]
|
| 10 |
-
PROVENANCE_PATH = ROOT / "tools/release_provenance.py"
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
def load_module(path: Path, name: str):
|
| 14 |
-
spec = importlib.util.spec_from_file_location(name, path)
|
| 15 |
-
if spec is None or spec.loader is None:
|
| 16 |
-
raise RuntimeError(f"Unable to load {name}")
|
| 17 |
-
module = importlib.util.module_from_spec(spec)
|
| 18 |
-
sys.modules[spec.name] = module
|
| 19 |
-
spec.loader.exec_module(module)
|
| 20 |
-
return module
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
def run_git(cwd: Path, *args: str) -> str:
|
| 24 |
-
result = subprocess.run(
|
| 25 |
-
["git", *args],
|
| 26 |
-
cwd=cwd,
|
| 27 |
-
check=True,
|
| 28 |
-
capture_output=True,
|
| 29 |
-
text=True,
|
| 30 |
-
encoding="utf-8",
|
| 31 |
-
)
|
| 32 |
-
return result.stdout.strip()
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
class RepositoryProvenanceTests(unittest.TestCase):
|
| 36 |
-
@classmethod
|
| 37 |
-
def setUpClass(cls):
|
| 38 |
-
if not PROVENANCE_PATH.is_file():
|
| 39 |
-
raise AssertionError("tools/release_provenance.py is required")
|
| 40 |
-
cls.provenance = load_module(PROVENANCE_PATH, "release_provenance")
|
| 41 |
-
|
| 42 |
-
def setUp(self):
|
| 43 |
-
self.temporary_directory = tempfile.TemporaryDirectory()
|
| 44 |
-
self.base = Path(self.temporary_directory.name)
|
| 45 |
-
|
| 46 |
-
def tearDown(self):
|
| 47 |
-
self.temporary_directory.cleanup()
|
| 48 |
-
|
| 49 |
-
def create_remote(self) -> Path:
|
| 50 |
-
remote = self.base / "remote.git"
|
| 51 |
-
seed = self.base / "seed"
|
| 52 |
-
run_git(self.base, "init", "--bare", str(remote))
|
| 53 |
-
run_git(remote, "symbolic-ref", "HEAD", "refs/heads/main")
|
| 54 |
-
run_git(self.base, "init", "-b", "main", str(seed))
|
| 55 |
-
run_git(seed, "config", "user.name", "Release Test")
|
| 56 |
-
run_git(seed, "config", "user.email", "release-test@example.invalid")
|
| 57 |
-
run_git(seed, "config", "core.autocrlf", "false")
|
| 58 |
-
(seed / "README.md").write_text("release\n", encoding="utf-8")
|
| 59 |
-
run_git(seed, "add", "README.md")
|
| 60 |
-
run_git(seed, "commit", "-m", "initial release")
|
| 61 |
-
run_git(seed, "tag", "-a", "v1.1.2", "-m", "v1.1.2")
|
| 62 |
-
run_git(seed, "remote", "add", "origin", str(remote))
|
| 63 |
-
run_git(seed, "push", "-u", "origin", "main")
|
| 64 |
-
run_git(seed, "push", "origin", "v1.1.2")
|
| 65 |
-
return remote
|
| 66 |
-
|
| 67 |
-
def clone_remote(self, remote: Path, *, no_tags: bool = False) -> Path:
|
| 68 |
-
clone = self.base / ("clone-no-tags" if no_tags else "clone")
|
| 69 |
-
args = ["-c", "core.autocrlf=false", "clone"]
|
| 70 |
-
if no_tags:
|
| 71 |
-
args.append("--no-tags")
|
| 72 |
-
args.extend([str(remote), str(clone)])
|
| 73 |
-
run_git(self.base, *args)
|
| 74 |
-
run_git(clone, "config", "user.name", "Release Test")
|
| 75 |
-
run_git(clone, "config", "user.email", "release-test@example.invalid")
|
| 76 |
-
run_git(clone, "config", "core.autocrlf", "false")
|
| 77 |
-
return clone
|
| 78 |
-
|
| 79 |
-
def inspect(self, root: Path, version: str, remote: Path):
|
| 80 |
-
return self.provenance.inspect_repository(
|
| 81 |
-
root,
|
| 82 |
-
version,
|
| 83 |
-
files=("README.md",),
|
| 84 |
-
expected_origin=str(remote.resolve()),
|
| 85 |
-
)
|
| 86 |
-
|
| 87 |
-
def test_tagless_release_cannot_be_publication_ready(self):
|
| 88 |
-
candidate = self.base / "release"
|
| 89 |
-
candidate.mkdir()
|
| 90 |
-
(candidate / "README.md").write_text("altered release\n", encoding="utf-8")
|
| 91 |
-
|
| 92 |
-
result = self.provenance.inspect_repository(
|
| 93 |
-
candidate,
|
| 94 |
-
"1.1.2",
|
| 95 |
-
files=("README.md",),
|
| 96 |
-
expected_origin="https://github.com/Lifted-Holdings/payment-processing-resources",
|
| 97 |
-
)
|
| 98 |
-
|
| 99 |
-
self.assertFalse(result.publication_ready)
|
| 100 |
-
self.assertIn("git_metadata_missing", result.failure_codes)
|
| 101 |
-
|
| 102 |
-
def test_existing_remote_tag_missing_locally_is_not_treated_as_new(self):
|
| 103 |
-
remote = self.create_remote()
|
| 104 |
-
clone = self.clone_remote(remote, no_tags=True)
|
| 105 |
-
|
| 106 |
-
result = self.inspect(clone, "1.1.2", remote)
|
| 107 |
-
|
| 108 |
-
self.assertFalse(result.publication_ready)
|
| 109 |
-
self.assertIn("local_release_tag_missing", result.failure_codes)
|
| 110 |
-
|
| 111 |
-
def test_dirty_tracked_candidate_is_blocked(self):
|
| 112 |
-
remote = self.create_remote()
|
| 113 |
-
clone = self.clone_remote(remote)
|
| 114 |
-
(clone / "README.md").write_text("dirty\n", encoding="utf-8")
|
| 115 |
-
|
| 116 |
-
result = self.inspect(clone, "1.1.2", remote)
|
| 117 |
-
|
| 118 |
-
self.assertFalse(result.publication_ready)
|
| 119 |
-
self.assertIn("working_tree_dirty", result.failure_codes)
|
| 120 |
-
|
| 121 |
-
def test_untracked_candidate_asset_is_blocked(self):
|
| 122 |
-
remote = self.create_remote()
|
| 123 |
-
clone = self.clone_remote(remote)
|
| 124 |
-
(clone / "undeclared.txt").write_text("untracked\n", encoding="utf-8")
|
| 125 |
-
|
| 126 |
-
result = self.inspect(clone, "1.1.2", remote)
|
| 127 |
-
|
| 128 |
-
self.assertFalse(result.publication_ready)
|
| 129 |
-
self.assertIn("working_tree_dirty", result.failure_codes)
|
| 130 |
-
|
| 131 |
-
def test_local_and_remote_release_tag_mismatch_is_blocked(self):
|
| 132 |
-
remote = self.create_remote()
|
| 133 |
-
clone = self.clone_remote(remote)
|
| 134 |
-
(clone / "README.md").write_text("second commit\n", encoding="utf-8")
|
| 135 |
-
run_git(clone, "add", "README.md")
|
| 136 |
-
run_git(clone, "commit", "-m", "second commit")
|
| 137 |
-
run_git(clone, "tag", "-f", "v1.1.2")
|
| 138 |
-
|
| 139 |
-
result = self.inspect(clone, "1.1.2", remote)
|
| 140 |
-
|
| 141 |
-
self.assertFalse(result.publication_ready)
|
| 142 |
-
self.assertIn("remote_tag_mismatch", result.failure_codes)
|
| 143 |
-
|
| 144 |
-
def test_lower_untagged_version_is_blocked_by_highest_remote_release(self):
|
| 145 |
-
remote = self.create_remote()
|
| 146 |
-
clone = self.clone_remote(remote, no_tags=True)
|
| 147 |
-
|
| 148 |
-
result = self.inspect(clone, "1.1.1", remote)
|
| 149 |
-
|
| 150 |
-
self.assertFalse(result.publication_ready)
|
| 151 |
-
self.assertIn("version_not_monotonic", result.failure_codes)
|
| 152 |
-
|
| 153 |
-
def test_newer_untagged_version_can_pass_repository_provenance(self):
|
| 154 |
-
remote = self.create_remote()
|
| 155 |
-
clone = self.clone_remote(remote, no_tags=True)
|
| 156 |
-
|
| 157 |
-
result = self.inspect(clone, "1.1.3", remote)
|
| 158 |
-
|
| 159 |
-
self.assertTrue(result.publication_ready, result.failure_codes)
|
| 160 |
-
self.assertEqual("new", result.release_state)
|
| 161 |
-
self.assertEqual((), result.failure_codes)
|
| 162 |
-
|
| 163 |
-
def test_untrusted_origin_is_blocked(self):
|
| 164 |
-
remote = self.create_remote()
|
| 165 |
-
clone = self.clone_remote(remote)
|
| 166 |
-
|
| 167 |
-
result = self.provenance.inspect_repository(
|
| 168 |
-
clone,
|
| 169 |
-
"1.1.2",
|
| 170 |
-
files=("README.md",),
|
| 171 |
-
expected_origin="https://github.com/Lifted-Holdings/payment-processing-resources",
|
| 172 |
-
)
|
| 173 |
-
|
| 174 |
-
self.assertFalse(result.publication_ready)
|
| 175 |
-
self.assertIn("origin_untrusted", result.failure_codes)
|
| 176 |
-
|
| 177 |
-
def test_exact_annotated_release_tag_and_clean_tree_pass(self):
|
| 178 |
-
remote = self.create_remote()
|
| 179 |
-
clone = self.clone_remote(remote)
|
| 180 |
-
|
| 181 |
-
result = self.inspect(clone, "1.1.2", remote)
|
| 182 |
-
|
| 183 |
-
self.assertTrue(result.publication_ready, result.failure_codes)
|
| 184 |
-
self.assertEqual("tagged", result.release_state)
|
| 185 |
-
self.assertRegex(result.head_commit or "", r"^[0-9a-f]{40}$")
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
if __name__ == "__main__":
|
| 189 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|