Liftedholdings commited on
Commit
089d5af
·
verified ·
1 Parent(s): f761299

Publish hardened v1.1.0 statement audit model

Browse files
CITATION.cff ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0
8
+ date-released: 2026-08-02
9
+ doi: "10.5281/zenodo.21762273"
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 ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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`. |
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 ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Creative Commons Attribution 4.0 International
2
+
3
+ This work is licensed under the Creative Commons Attribution 4.0 International License.
4
+
5
+ You are free to share and adapt this material for any purpose, including commercially, provided that you give appropriate credit, link to the license, and indicate whether changes were made. You may not apply legal or technological restrictions that prevent others from doing anything the license permits.
6
+
7
+ The complete legal code is available at https://creativecommons.org/licenses/by/4.0/legalcode.
8
+
9
+ Suggested attribution:
10
+
11
+ > Lifted Payments payment statement audit model — https://liftedpayments.com/payment-processing-statement-audit/
METHODOLOGY.md ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ## What the effective rate can and cannot show
29
+
30
+ 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.
31
+
32
+ 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.
33
+
34
+ ## Validation architecture
35
+
36
+ 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.
37
+
38
+ 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.
39
+
40
+ ## Privacy and security boundary
41
+
42
+ 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.
43
+
44
+ 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.
45
+
46
+ ## Corrections and versioning
47
+
48
+ 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
@@ -1,3 +1,90 @@
1
  ---
2
  license: cc-by-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 version **1.1.0** of the schema, 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.21762273
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.0
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.0). Zenodo. https://doi.org/10.5281/zenodo.21762273
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.
RELEASE-MANIFEST.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "title": "Lifted Payments Payment Statement Audit Model",
3
+ "version": "1.1.0",
4
+ "version_doi": "10.5281/zenodo.21762273",
5
+ "concept_doi": "10.5281/zenodo.21761714",
6
+ "canonical_url": "https://liftedpayments.com/payment-processing-statement-audit/",
7
+ "source_release": "https://github.com/Lifted-Holdings/payment-processing-resources/releases/tag/v1.1.0",
8
+ "license": "CC-BY-4.0",
9
+ "files": [
10
+ ".zenodo.json",
11
+ "CITATION.cff",
12
+ "checksums.txt",
13
+ "codemeta.json",
14
+ "DATA_DICTIONARY.md",
15
+ "distribution/huggingface/README.md",
16
+ "distribution/kaggle/dataset-metadata.json",
17
+ "distribution/kaggle/README.md",
18
+ "examples/payment-statement-audit-example.json",
19
+ "LICENSE.md",
20
+ "llms.txt",
21
+ "METHODOLOGY.md",
22
+ "payment-statement-audit-template.csv",
23
+ "README.md",
24
+ "RELEASE-MANIFEST.json",
25
+ "requirements-validation.txt",
26
+ "schema/payment-statement-audit.schema.json",
27
+ "test-vectors/invalid/activity-mismatch.json",
28
+ "test-vectors/invalid/duplicate-category.json",
29
+ "test-vectors/invalid/fee-sum-mismatch.json",
30
+ "test-vectors/invalid/fractional-cent.json",
31
+ "test-vectors/invalid/invalid-date.json",
32
+ "test-vectors/invalid/net-fee-mismatch.json",
33
+ "test-vectors/invalid/overlong-period.json",
34
+ "test-vectors/invalid/overprecise-rate.json",
35
+ "test-vectors/invalid/security-data-in-note.json",
36
+ "test-vectors/invalid/reversed-period.json",
37
+ "test-vectors/invalid/unknown-field.json",
38
+ "test-vectors/invalid/wrong-average-ticket.json",
39
+ "test-vectors/invalid/wrong-effective-rate.json",
40
+ "test-vectors/manifest.json",
41
+ "test-vectors/valid/standard-month.json",
42
+ "test-vectors/valid/zero-activity-month.json",
43
+ "tools/publication_gate.py",
44
+ "tools/update_checksums.py",
45
+ "tools/validate_audit.py",
46
+ "validation-report.json"
47
+ ]
48
+ }
checksums.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 955f069a776b7a49ac99d6c9ccf7f8a7f065f6bef89344f819b8bb2f940c67f2 .zenodo.json
2
+ c5b80e64c2f01e4622a086bca302b91a46061b806dc26521ed691a97fab31423 CITATION.cff
3
+ 6f37348b42d96d8d1ca6385033bfda91efc26353709eeb46e91e38db9801a323 DATA_DICTIONARY.md
4
+ 248c65ad6ddbd9dd29a4b753d312a15016a8062d55646e19e222f0ac42485b96 LICENSE.md
5
+ 3a8a8390a9d890c522c5f20c40281b169bfc5d3b19c11ee2705753402aad6857 METHODOLOGY.md
6
+ 2d4c2f6f581dd68af3dd9a7f7f97b1f3fd04c5a55af963a8d57db7dc2ed4f615 README.md
7
+ e8e72a5d203d0773dc82ca219c12bb9fec332ef52515b08b0a27c9964e982697 RELEASE-MANIFEST.json
8
+ fef0aa9f3e2db36c79020b1084102a454d6734ed8e5e04fd1c61d84eef688c8e codemeta.json
9
+ fd10af02d6d9a986f8899d9eb3a4023c8374441f2e02632c95ab7cc427cc5f04 distribution/huggingface/README.md
10
+ 23904ebf11ecfae3b0df5979239df82b143b12ff48e06cff0ac5d9bbb2eb6f96 distribution/kaggle/README.md
11
+ 7187b4977f7c3a518475c9d0f989a7d8cc71b8e5a23f5b10608bad8b8fcdf16f distribution/kaggle/dataset-metadata.json
12
+ 7a3299b4490d0e7f0c1a99a48859bce9742f632d8796699d80a48221e9fa38af examples/payment-statement-audit-example.json
13
+ f08d1dc8fe55a054d2947e6c57558c2daa632caf86f0e6296b9e36bc7a85de45 llms.txt
14
+ 51cde2dd0d9da13e47c50228f96f8cc624662b5edcccb3f95719f53a79a1a47c payment-statement-audit-template.csv
15
+ d53f1737b5cb16cd8ad3c79ae4082ff35b0f120eb45bd502a042b3e5f275ac1f requirements-validation.txt
16
+ 5979ec9c587be20ae723879f3863edb1f5a78ccddc848ca9a183b58532271730 schema/payment-statement-audit.schema.json
17
+ 3bad5c0b256a0a65640515c00d6e1eea316039f57e3ec08a6809eee4c75f176a test-vectors/invalid/activity-mismatch.json
18
+ 2ee2c9552d3728bcddce248cf3a3b8c12ec06c5923f48412688e544c69cdb78a test-vectors/invalid/duplicate-category.json
19
+ 57f100181eb71060b16d3ae9e1861ef1eb79940f0bf7f4f1e618a97bb1e4415d test-vectors/invalid/fee-sum-mismatch.json
20
+ dd522dff07da399c5fc46d2d02a4cb9109c7f1860ec58a4849392e9aff853f52 test-vectors/invalid/fractional-cent.json
21
+ 23c4e68b176b807df6738a4b0a9a8adbddbf9ddaee26d0b4262a6905652af951 test-vectors/invalid/invalid-date.json
22
+ 0ef3f62501948cd15f7d69b4b64f43c78cb110f9937f5a2115e2e7e7f85eb0c7 test-vectors/invalid/net-fee-mismatch.json
23
+ caeb952d6e2c93597b6f7def52616e7b390c8f8807b9740a4ae6acb6ecba1d30 test-vectors/invalid/overlong-period.json
24
+ fb401b20ccfa0b3278948e60dbc7efc9e6c140d9facc7a58ddceb09ebfa32029 test-vectors/invalid/overprecise-rate.json
25
+ 96aa4e395b6fb9154673602441429aaf3cb3cb962899f3f9b355b4cfb0fb6d17 test-vectors/invalid/reversed-period.json
26
+ 5a1821ccd329b53e393dd27d6eca8c4da7ed09f9963d36efe7eb2bfe7f47c0d9 test-vectors/invalid/security-data-in-note.json
27
+ a102b3b69c9260579982d5d668a57ab5494d1baba89fe8d93cd1b5ef5d564572 test-vectors/invalid/unknown-field.json
28
+ 8520c8dc0244c121e85e39ae63af1846e15acf902355afa0ce515838c6160b7b test-vectors/invalid/wrong-average-ticket.json
29
+ b185d1eb11f805c1dac0e0a5aa69be8bb35fbed1079673a3e8a2abba45d83a36 test-vectors/invalid/wrong-effective-rate.json
30
+ 067df78c1143d18c5daa86467fd51ef760653a4aa7b15213eb381bd56dd39377 test-vectors/manifest.json
31
+ d73ed747b481e60c3c4502a1738997f04a6a5c63ceb1268ebd4e4fb8e3e0baea test-vectors/valid/standard-month.json
32
+ 9a0f4872a6b588d246954727deb02bc5b7e82bac9921efb5ebf1e0b27a558a10 test-vectors/valid/zero-activity-month.json
33
+ 405138c1c7f07a9d50b1285d94ddb8222283bde8c30c4f8ffc73fe909a71ae12 tools/publication_gate.py
34
+ 9efff7ec3bfff067abaaf8a5d2c5008c3aaf0bf7b25c49ff623c37552de6bb10 tools/update_checksums.py
35
+ 876cc506196772369a5b2afcc2e8f72e072268db1cdf61dea0978ea81ae27b0b tools/validate_audit.py
36
+ 1498a6ad7c1c48f48fe4b15bc8ac1a2188fdb557f1e51b159b8dca673b6839b2 validation-report.json
codemeta.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0",
7
+ "datePublished": "2026-08-02",
8
+ "license": "https://creativecommons.org/licenses/by/4.0/",
9
+ "identifier": "https://doi.org/10.5281/zenodo.21762273",
10
+ "url": "https://liftedpayments.com/payment-processing-statement-audit/",
11
+ "sameAs": [
12
+ "https://doi.org/10.5281/zenodo.21762273",
13
+ "https://doi.org/10.5281/zenodo.21761714",
14
+ "https://zenodo.org/records/21762273"
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
+ }
examples/payment-statement-audit-example.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
payment-statement-audit-template.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
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
requirements-validation.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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/reversed-period.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
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 ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "invalid": {
3
+ "activity-mismatch.json": ["activity_pair"],
4
+ "duplicate-category.json": ["duplicate_fee_category"],
5
+ "fee-sum-mismatch.json": ["fee_group_reconciliation"],
6
+ "fractional-cent.json": ["money_precision"],
7
+ "invalid-date.json": ["schema_format"],
8
+ "net-fee-mismatch.json": ["net_fee_reconciliation"],
9
+ "overlong-period.json": ["period_duration"],
10
+ "overprecise-rate.json": ["rate_precision"],
11
+ "security-data-in-note.json": ["prohibited_payment_data"],
12
+ "reversed-period.json": ["period_order"],
13
+ "unknown-field.json": ["schema_additionalProperties"],
14
+ "wrong-average-ticket.json": ["average_ticket_mismatch"],
15
+ "wrong-effective-rate.json": ["effective_rate_mismatch"]
16
+ }
17
+ }
test-vectors/valid/standard-month.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
tools/validate_audit.py ADDED
@@ -0,0 +1,608 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Validate Lifted Payments statement-audit records without echoing input values."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import csv
8
+ import hashlib
9
+ import json
10
+ import re
11
+ from dataclasses import asdict, dataclass
12
+ from datetime import date
13
+ from decimal import Decimal, InvalidOperation, ROUND_HALF_UP
14
+ from importlib.metadata import version as package_version
15
+ from pathlib import Path
16
+ from typing import Any, Iterable
17
+
18
+ from jsonschema import Draft202012Validator, FormatChecker, validators
19
+
20
+
21
+ ROOT = Path(__file__).resolve().parents[1]
22
+ SCHEMA_PATH = ROOT / "schema/payment-statement-audit.schema.json"
23
+ VALIDATOR_VERSION = "1.1.0"
24
+ VALIDATION_DEPENDENCIES = (
25
+ "attrs",
26
+ "jsonschema",
27
+ "jsonschema-specifications",
28
+ "referencing",
29
+ "rpds-py",
30
+ )
31
+ MAX_PERIOD_DAYS = 62
32
+ MAX_INPUT_BYTES = 1_000_000
33
+ MAX_INPUT_DEPTH = 32
34
+ MONEY_QUANTUM = Decimal("0.01")
35
+ RATE_QUANTUM = Decimal("0.000001")
36
+ FEE_CATEGORIES = (
37
+ "interchange",
38
+ "assessments",
39
+ "processor_markup",
40
+ "authorization",
41
+ "monthly",
42
+ "pci",
43
+ "equipment",
44
+ "chargebacks",
45
+ "other",
46
+ )
47
+ CSV_HEADER = (
48
+ "schema_version",
49
+ "calculation_basis",
50
+ "statement_start",
51
+ "statement_end",
52
+ "currency",
53
+ "card_volume",
54
+ "transaction_count",
55
+ "gross_processing_fees",
56
+ "statement_credits",
57
+ "total_processing_fees",
58
+ "effective_rate",
59
+ "average_ticket",
60
+ "pricing_model",
61
+ *FEE_CATEGORIES,
62
+ "notes",
63
+ )
64
+
65
+ _PAN_CANDIDATE = re.compile(r"(?<!\d)(?:\d[ -]?){13,19}(?!\d)")
66
+ _SSN = re.compile(r"(?<!\d)\d{3}-\d{2}-\d{4}(?!\d)")
67
+ _EMAIL = re.compile(r"\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b", re.I)
68
+ _AUTHENTICATION_LABEL = re.compile(
69
+ r"\b(?:cvv2?|cvc2?|cid|security\s*code|pin(?:\s*block)?)\b",
70
+ re.I,
71
+ )
72
+ _BANK_VALUE = re.compile(
73
+ r"\b(?:routing|account)(?:\s*(?:number|no))?\b[^\r\n\d]{0,12}\d{4,}",
74
+ re.I,
75
+ )
76
+ _LABELED_CREDENTIAL = re.compile(
77
+ r"\b(?:password|api[_ -]?key|bearer|secret|access[_ -]?token)\b"
78
+ r"\s*(?::|=|is)\s*[A-Za-z0-9_-]{3,}",
79
+ re.I,
80
+ )
81
+ _CREDENTIAL = re.compile(
82
+ r"\b(?:sk|pk|ghp|github_pat|hf)_[A-Za-z0-9_-]{12,}\b", re.I
83
+ )
84
+ _PROHIBITED_KEY = re.compile(
85
+ r"(?:pan|card_?number|cvv|cvc|security_?code|pin_?block|routing_?number|"
86
+ r"bank_?account|account_?number|ssn|password|api_?key|secret|token)",
87
+ re.I,
88
+ )
89
+
90
+
91
+ @dataclass(frozen=True, order=True)
92
+ class ValidationIssue:
93
+ code: str
94
+ path: str
95
+ message: str
96
+
97
+ def to_dict(self) -> dict[str, str]:
98
+ return asdict(self)
99
+
100
+
101
+ def _reject_constant(_: str) -> None:
102
+ raise ValueError("non_finite_number: JSON numbers must be finite")
103
+
104
+
105
+ def _unique_object(pairs: list[tuple[str, Any]]) -> dict[str, Any]:
106
+ result: dict[str, Any] = {}
107
+ for key, value in pairs:
108
+ if key in result:
109
+ raise ValueError("duplicate_key: JSON object keys must be unique")
110
+ result[key] = value
111
+ return result
112
+
113
+
114
+ def loads_record(source: str) -> dict[str, Any]:
115
+ if len(source.encode("utf-8")) > MAX_INPUT_BYTES:
116
+ raise ValueError("input_size: audit record exceeds the one-megabyte limit")
117
+ try:
118
+ result = json.loads(
119
+ source,
120
+ parse_float=Decimal,
121
+ parse_int=int,
122
+ parse_constant=_reject_constant,
123
+ object_pairs_hook=_unique_object,
124
+ )
125
+ except (json.JSONDecodeError, RecursionError) as exc:
126
+ raise ValueError("invalid_json: input is not valid JSON") from exc
127
+ if not isinstance(result, dict):
128
+ raise ValueError("invalid_root: audit record must be a JSON object")
129
+ stack: list[tuple[Any, int]] = [(result, 1)]
130
+ while stack:
131
+ value, depth = stack.pop()
132
+ if depth > MAX_INPUT_DEPTH:
133
+ raise ValueError("input_depth: audit record is nested too deeply")
134
+ if isinstance(value, dict):
135
+ stack.extend((child, depth + 1) for child in value.values())
136
+ elif isinstance(value, list):
137
+ stack.extend((child, depth + 1) for child in value)
138
+ return result
139
+
140
+
141
+ def load_record(path: Path | str) -> dict[str, Any]:
142
+ path = Path(path)
143
+ if path.stat().st_size > MAX_INPUT_BYTES:
144
+ raise ValueError("input_size: audit record exceeds the one-megabyte limit")
145
+ return loads_record(path.read_text(encoding="utf-8"))
146
+
147
+
148
+ def _schema_validator() -> Draft202012Validator:
149
+ schema = json.loads(SCHEMA_PATH.read_text(encoding="utf-8"))
150
+ Draft202012Validator.check_schema(schema)
151
+ number_check = Draft202012Validator.TYPE_CHECKER.redefine(
152
+ "number",
153
+ lambda checker, instance: (
154
+ not isinstance(instance, bool)
155
+ and isinstance(instance, (int, float, Decimal))
156
+ ),
157
+ )
158
+ decimal_validator = validators.extend(
159
+ Draft202012Validator, type_checker=number_check
160
+ )
161
+ return decimal_validator(schema, format_checker=FormatChecker())
162
+
163
+
164
+ def _pointer(parts: Iterable[Any]) -> str:
165
+ encoded = [str(part).replace("~", "~0").replace("/", "~1") for part in parts]
166
+ return "/" + "/".join(encoded) if encoded else "/"
167
+
168
+
169
+ def _schema_issues(record: dict[str, Any]) -> list[ValidationIssue]:
170
+ issues = []
171
+ for error in sorted(
172
+ _schema_validator().iter_errors(record),
173
+ key=lambda error: _pointer(error.absolute_path),
174
+ ):
175
+ validator_name = str(error.validator or "validation")
176
+ issues.append(
177
+ ValidationIssue(
178
+ code=f"schema_{validator_name}",
179
+ path=_pointer(error.absolute_path),
180
+ message=f"Record violates the schema {validator_name} rule.",
181
+ )
182
+ )
183
+ return issues
184
+
185
+
186
+ def _decimal(value: Any) -> Decimal | None:
187
+ if isinstance(value, bool) or value is None:
188
+ return None
189
+ try:
190
+ result = value if isinstance(value, Decimal) else Decimal(str(value))
191
+ except (InvalidOperation, ValueError):
192
+ return None
193
+ return result if result.is_finite() else None
194
+
195
+
196
+ def _has_scale(value: Any, places: int) -> bool:
197
+ number = _decimal(value)
198
+ return number is not None and number.as_tuple().exponent >= -places
199
+
200
+
201
+ def _luhn_valid(digits: str) -> bool:
202
+ total = 0
203
+ parity = len(digits) % 2
204
+ for index, char in enumerate(digits):
205
+ value = int(char)
206
+ if index % 2 == parity:
207
+ value *= 2
208
+ if value > 9:
209
+ value -= 9
210
+ total += value
211
+ return total % 10 == 0
212
+
213
+
214
+ def _string_contains_prohibited_data(value: str) -> bool:
215
+ if _SSN.search(value) or _EMAIL.search(value) or _CREDENTIAL.search(value):
216
+ return True
217
+ for candidate in _PAN_CANDIDATE.finditer(value):
218
+ digits = re.sub(r"\D", "", candidate.group(0))
219
+ if 13 <= len(digits) <= 19 and _luhn_valid(digits):
220
+ return True
221
+ if (
222
+ _AUTHENTICATION_LABEL.search(value)
223
+ or _BANK_VALUE.search(value)
224
+ or _LABELED_CREDENTIAL.search(value)
225
+ ):
226
+ return True
227
+ return False
228
+
229
+
230
+ def _privacy_issues(value: Any, path: tuple[Any, ...] = ()) -> list[ValidationIssue]:
231
+ issues: list[ValidationIssue] = []
232
+ if isinstance(value, dict):
233
+ for key, child in value.items():
234
+ child_path = (*path, key)
235
+ if _PROHIBITED_KEY.search(key):
236
+ issues.append(
237
+ ValidationIssue(
238
+ "prohibited_field",
239
+ _pointer(child_path),
240
+ "A prohibited payment, identity, bank, or credential field is present.",
241
+ )
242
+ )
243
+ issues.extend(_privacy_issues(child, child_path))
244
+ elif isinstance(value, list):
245
+ for index, child in enumerate(value):
246
+ issues.extend(_privacy_issues(child, (*path, index)))
247
+ elif isinstance(value, str) and _string_contains_prohibited_data(value):
248
+ issues.append(
249
+ ValidationIssue(
250
+ "prohibited_payment_data",
251
+ _pointer(path),
252
+ "Text may contain prohibited payment, identity, bank, or credential data.",
253
+ )
254
+ )
255
+ return issues
256
+
257
+
258
+ def _semantic_issues(record: dict[str, Any]) -> list[ValidationIssue]:
259
+ issues: list[ValidationIssue] = []
260
+
261
+ period = record.get("statement_period")
262
+ if isinstance(period, dict):
263
+ try:
264
+ start = date.fromisoformat(period["start"])
265
+ end = date.fromisoformat(period["end"])
266
+ except (KeyError, TypeError, ValueError):
267
+ start = end = None
268
+ if start is not None and end is not None:
269
+ if end < start:
270
+ issues.append(
271
+ ValidationIssue(
272
+ "period_order",
273
+ "/statement_period",
274
+ "Statement period end must not precede start.",
275
+ )
276
+ )
277
+ elif (end - start).days + 1 > MAX_PERIOD_DAYS:
278
+ issues.append(
279
+ ValidationIssue(
280
+ "period_duration",
281
+ "/statement_period",
282
+ f"Statement period must cover no more than {MAX_PERIOD_DAYS} inclusive days.",
283
+ )
284
+ )
285
+
286
+ money_paths: list[tuple[str, Any]] = [
287
+ (f"/{name}", record.get(name))
288
+ for name in (
289
+ "card_volume",
290
+ "gross_processing_fees",
291
+ "statement_credits",
292
+ "total_processing_fees",
293
+ "average_ticket",
294
+ )
295
+ if record.get(name) is not None
296
+ ]
297
+ groups = record.get("fee_groups")
298
+ if isinstance(groups, list):
299
+ for index, group in enumerate(groups):
300
+ if isinstance(group, dict) and group.get("amount") is not None:
301
+ money_paths.append((f"/fee_groups/{index}/amount", group["amount"]))
302
+ for path, value in money_paths:
303
+ if _decimal(value) is not None and not _has_scale(value, 2):
304
+ issues.append(
305
+ ValidationIssue(
306
+ "money_precision",
307
+ path,
308
+ "USD amounts must use no more than two decimal places.",
309
+ )
310
+ )
311
+
312
+ rate = record.get("effective_rate")
313
+ if rate is not None and _decimal(rate) is not None and not _has_scale(rate, 6):
314
+ issues.append(
315
+ ValidationIssue(
316
+ "rate_precision",
317
+ "/effective_rate",
318
+ "Effective rate must use no more than six decimal places.",
319
+ )
320
+ )
321
+
322
+ if isinstance(groups, list):
323
+ categories = [
324
+ group.get("category") for group in groups if isinstance(group, dict)
325
+ ]
326
+ if len(categories) != len(set(categories)):
327
+ issues.append(
328
+ ValidationIssue(
329
+ "duplicate_fee_category",
330
+ "/fee_groups",
331
+ "Each fee category may appear at most once.",
332
+ )
333
+ )
334
+ amounts = [
335
+ _decimal(group.get("amount"))
336
+ for group in groups
337
+ if isinstance(group, dict)
338
+ ]
339
+ gross = _decimal(record.get("gross_processing_fees"))
340
+ if gross is not None and amounts and all(amount is not None for amount in amounts):
341
+ if sum((amount for amount in amounts if amount is not None), Decimal("0")) != gross:
342
+ issues.append(
343
+ ValidationIssue(
344
+ "fee_group_reconciliation",
345
+ "/gross_processing_fees",
346
+ "Fee-group amounts must exactly equal gross processing fees at cent precision.",
347
+ )
348
+ )
349
+
350
+ gross = _decimal(record.get("gross_processing_fees"))
351
+ credits = _decimal(record.get("statement_credits"))
352
+ net = _decimal(record.get("total_processing_fees"))
353
+ if gross is not None and credits is not None and net is not None:
354
+ if gross - credits != net:
355
+ issues.append(
356
+ ValidationIssue(
357
+ "net_fee_reconciliation",
358
+ "/total_processing_fees",
359
+ "Net processing fees must exactly equal gross fees minus statement credits.",
360
+ )
361
+ )
362
+
363
+ volume = _decimal(record.get("card_volume"))
364
+ count = record.get("transaction_count")
365
+ count_is_integer = isinstance(count, int) and not isinstance(count, bool)
366
+ if volume is not None and count_is_integer:
367
+ if (volume == 0) != (count == 0):
368
+ issues.append(
369
+ ValidationIssue(
370
+ "activity_pair",
371
+ "/transaction_count",
372
+ "Card volume and settled transaction count must both be zero or both be positive.",
373
+ )
374
+ )
375
+
376
+ if volume == 0:
377
+ if rate is not None:
378
+ issues.append(
379
+ ValidationIssue(
380
+ "zero_volume_rate",
381
+ "/effective_rate",
382
+ "Effective rate must be null when card volume is zero.",
383
+ )
384
+ )
385
+ elif net is not None:
386
+ observed_rate = _decimal(rate)
387
+ expected_rate = (net / volume).quantize(RATE_QUANTUM, rounding=ROUND_HALF_UP)
388
+ if observed_rate != expected_rate:
389
+ issues.append(
390
+ ValidationIssue(
391
+ "effective_rate_mismatch",
392
+ "/effective_rate",
393
+ "Effective rate does not match net fees divided by card volume at six-decimal rounding.",
394
+ )
395
+ )
396
+
397
+ ticket = record.get("average_ticket")
398
+ if count == 0:
399
+ if ticket is not None:
400
+ issues.append(
401
+ ValidationIssue(
402
+ "zero_count_ticket",
403
+ "/average_ticket",
404
+ "Average ticket must be null when transaction count is zero.",
405
+ )
406
+ )
407
+ elif volume is not None:
408
+ observed_ticket = _decimal(ticket)
409
+ expected_ticket = (volume / Decimal(count)).quantize(
410
+ MONEY_QUANTUM, rounding=ROUND_HALF_UP
411
+ )
412
+ if observed_ticket != expected_ticket:
413
+ issues.append(
414
+ ValidationIssue(
415
+ "average_ticket_mismatch",
416
+ "/average_ticket",
417
+ "Average ticket does not match card volume divided by transaction count at cent rounding.",
418
+ )
419
+ )
420
+
421
+ return issues
422
+
423
+
424
+ def validate_record(record: dict[str, Any]) -> list[ValidationIssue]:
425
+ issues = _schema_issues(record)
426
+ issues.extend(_semantic_issues(record))
427
+ issues.extend(_privacy_issues(record))
428
+ return sorted(set(issues))
429
+
430
+
431
+ def validation_result(record: dict[str, Any]) -> dict[str, Any]:
432
+ issues = validate_record(record)
433
+ return {
434
+ "validator_version": VALIDATOR_VERSION,
435
+ "status": "valid" if not issues else "invalid",
436
+ "issue_count": len(issues),
437
+ "issues": [issue.to_dict() for issue in issues],
438
+ }
439
+
440
+
441
+ def _record_from_csv(row: dict[str, str]) -> dict[str, Any]:
442
+ groups = []
443
+ for category in FEE_CATEGORIES:
444
+ amount = Decimal(row[category])
445
+ if amount != 0:
446
+ groups.append({"category": category, "amount": amount})
447
+ return {
448
+ "schema_version": row["schema_version"],
449
+ "calculation_basis": row["calculation_basis"],
450
+ "statement_period": {
451
+ "start": row["statement_start"],
452
+ "end": row["statement_end"],
453
+ },
454
+ "currency": row["currency"],
455
+ "card_volume": Decimal(row["card_volume"]),
456
+ "transaction_count": int(row["transaction_count"]),
457
+ "gross_processing_fees": Decimal(row["gross_processing_fees"]),
458
+ "statement_credits": Decimal(row["statement_credits"]),
459
+ "total_processing_fees": Decimal(row["total_processing_fees"]),
460
+ "effective_rate": (
461
+ None if not row["effective_rate"] else Decimal(row["effective_rate"])
462
+ ),
463
+ "average_ticket": (
464
+ None if not row["average_ticket"] else Decimal(row["average_ticket"])
465
+ ),
466
+ "pricing_model": row["pricing_model"],
467
+ "fee_groups": groups or [{"category": "other", "amount": Decimal("0.00")}],
468
+ "review_notes": [row["notes"]] if row["notes"] else [],
469
+ }
470
+
471
+
472
+ def validate_csv_template(path: Path | str) -> list[ValidationIssue]:
473
+ issues: list[ValidationIssue] = []
474
+ try:
475
+ with Path(path).open("r", encoding="utf-8", newline="") as handle:
476
+ reader = csv.DictReader(handle)
477
+ if tuple(reader.fieldnames or ()) != CSV_HEADER:
478
+ return [
479
+ ValidationIssue(
480
+ "csv_header",
481
+ "/",
482
+ "CSV columns do not match the versioned flat contract.",
483
+ )
484
+ ]
485
+ rows = list(reader)
486
+ except (OSError, UnicodeError, csv.Error):
487
+ return [
488
+ ValidationIssue("csv_read", "/", "CSV template could not be read safely.")
489
+ ]
490
+ if len(rows) != 1 or None in rows[0]:
491
+ return [
492
+ ValidationIssue(
493
+ "csv_example_count",
494
+ "/",
495
+ "CSV template must contain exactly one complete synthetic example row.",
496
+ )
497
+ ]
498
+ try:
499
+ issues.extend(validate_record(_record_from_csv(rows[0])))
500
+ except (InvalidOperation, KeyError, TypeError, ValueError):
501
+ issues.append(
502
+ ValidationIssue(
503
+ "csv_value",
504
+ "/",
505
+ "CSV example contains an invalid typed value.",
506
+ )
507
+ )
508
+ return sorted(set(issues))
509
+
510
+
511
+ def _sha256(path: Path) -> str:
512
+ return hashlib.sha256(path.read_bytes()).hexdigest()
513
+
514
+
515
+ def build_corpus_report(root: Path | str = ROOT) -> dict[str, Any]:
516
+ root = Path(root)
517
+ manifest_path = root / "test-vectors/manifest.json"
518
+ manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
519
+ valid_files = sorted((root / "test-vectors/valid").glob("*.json"))
520
+ invalid_expectations = manifest.get("invalid", {})
521
+ unexpected: list[dict[str, str]] = []
522
+
523
+ for path in valid_files:
524
+ try:
525
+ issues = validate_record(load_record(path))
526
+ except ValueError:
527
+ issues = [ValidationIssue("parse_error", "/", "Record could not be parsed.")]
528
+ if issues:
529
+ unexpected.append({"file": path.name, "result": "unexpected_invalid"})
530
+
531
+ invalid_dir = root / "test-vectors/invalid"
532
+ for filename, expected_codes in sorted(invalid_expectations.items()):
533
+ path = invalid_dir / filename
534
+ try:
535
+ observed = {issue.code for issue in validate_record(load_record(path))}
536
+ except ValueError as exc:
537
+ observed = {str(exc).split(":", maxsplit=1)[0]}
538
+ if not set(expected_codes).issubset(observed):
539
+ unexpected.append({"file": filename, "result": "expected_rule_not_observed"})
540
+
541
+ csv_issues = validate_csv_template(root / "payment-statement-audit-template.csv")
542
+ if csv_issues:
543
+ unexpected.append({"file": "payment-statement-audit-template.csv", "result": "invalid"})
544
+
545
+ return {
546
+ "report_version": "1.0",
547
+ "validator_version": VALIDATOR_VERSION,
548
+ "status": "pass" if not unexpected else "fail",
549
+ "valid_vectors": len(valid_files),
550
+ "invalid_vectors": len(invalid_expectations),
551
+ "unexpected_results": len(unexpected),
552
+ "unexpected": unexpected,
553
+ "schema_sha256": _sha256(root / "schema/payment-statement-audit.schema.json"),
554
+ "validator_sha256": _sha256(root / "tools/validate_audit.py"),
555
+ "jsonschema_version": package_version("jsonschema"),
556
+ "dependency_versions": {
557
+ name: package_version(name) for name in VALIDATION_DEPENDENCIES
558
+ },
559
+ }
560
+
561
+
562
+ def _parse_args(argv: list[str] | None) -> argparse.Namespace:
563
+ parser = argparse.ArgumentParser(
564
+ description="Validate a v1.1.0 Lifted Payments statement-audit JSON record."
565
+ )
566
+ parser.add_argument("path", nargs="?", type=Path)
567
+ parser.add_argument("--json", action="store_true", dest="as_json")
568
+ parser.add_argument("--corpus", action="store_true")
569
+ return parser.parse_args(argv)
570
+
571
+
572
+ def main(argv: list[str] | None = None) -> int:
573
+ args = _parse_args(argv)
574
+ if args.corpus:
575
+ report = build_corpus_report(ROOT)
576
+ print(json.dumps(report, indent=2, sort_keys=True))
577
+ return 0 if report["status"] == "pass" else 1
578
+ if args.path is None:
579
+ raise SystemExit("A JSON path is required unless --corpus is used.")
580
+ try:
581
+ report = validation_result(load_record(args.path))
582
+ except (OSError, UnicodeError, ValueError) as exc:
583
+ code = str(exc).split(":", maxsplit=1)[0]
584
+ report = {
585
+ "validator_version": VALIDATOR_VERSION,
586
+ "status": "invalid",
587
+ "issue_count": 1,
588
+ "issues": [
589
+ ValidationIssue(
590
+ code=code,
591
+ path="/",
592
+ message="Input could not be parsed as a safe audit record.",
593
+ ).to_dict()
594
+ ],
595
+ }
596
+ if args.as_json:
597
+ print(json.dumps(report, indent=2, sort_keys=True))
598
+ elif report["status"] == "valid":
599
+ print("VALID: record satisfies the v1.1.0 structural, accounting, and privacy rules.")
600
+ else:
601
+ print(f"INVALID: {report['issue_count']} rule violation(s).")
602
+ for issue in report["issues"]:
603
+ print(f"- {issue['code']} at {issue['path']}: {issue['message']}")
604
+ return 0 if report["status"] == "valid" else 1
605
+
606
+
607
+ if __name__ == "__main__":
608
+ raise SystemExit(main())
validation-report.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dependency_versions": {
3
+ "attrs": "26.1.0",
4
+ "jsonschema": "4.26.0",
5
+ "jsonschema-specifications": "2025.9.1",
6
+ "referencing": "0.37.0",
7
+ "rpds-py": "2026.6.3"
8
+ },
9
+ "invalid_vectors": 13,
10
+ "jsonschema_version": "4.26.0",
11
+ "report_version": "1.0",
12
+ "schema_sha256": "5979ec9c587be20ae723879f3863edb1f5a78ccddc848ca9a183b58532271730",
13
+ "status": "pass",
14
+ "unexpected": [],
15
+ "unexpected_results": 0,
16
+ "valid_vectors": 2,
17
+ "validator_sha256": "876cc506196772369a5b2afcc2e8f72e072268db1cdf61dea0978ea81ae27b0b",
18
+ "validator_version": "1.1.0"
19
+ }