cbpr-validate 1.0.0__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/.gitignore +2 -0
- cbpr_validate-1.3.0/ARCHITECTURE.md +226 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/BUILD_PLAN.md +26 -5
- cbpr_validate-1.3.0/CHANGELOG.md +152 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/CLAUDE.md +22 -1
- cbpr_validate-1.3.0/KNOWN_ISSUES.md +126 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/PKG-INFO +111 -12
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/README.md +110 -11
- cbpr_validate-1.3.0/add_currencies.py +20 -0
- cbpr_validate-1.3.0/iso4217_currencies.json +172 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/pyproject.toml +5 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/__init__.py +1 -1
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/api/main.py +14 -1
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/cli.py +33 -6
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/codesets/data/iso20022_codesets.json +446 -276
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/core.py +156 -132
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/match/matcher.py +46 -28
- cbpr_validate-1.3.0/src/cbpr_validate/model/finding.py +67 -0
- cbpr_validate-1.3.0/src/cbpr_validate/model/validation_result.py +35 -0
- cbpr_validate-1.3.0/src/cbpr_validate/profiles.py +103 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/report/json_report.py +65 -57
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/report/junit_report.py +25 -2
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/report/text_report.py +15 -1
- cbpr_validate-1.3.0/src/cbpr_validate/rules/_return_amounts.py +140 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/rules/address.py +42 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/rules/amounts.py +93 -87
- cbpr_validate-1.3.0/src/cbpr_validate/rules/registry.py +82 -0
- cbpr_validate-1.3.0/src/cbpr_validate/rules/returns.py +140 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/conftest.py +4 -2
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_api.py +7 -2
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_cli.py +33 -14
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_core.py +14 -13
- cbpr_validate-1.3.0/tests/test_interface_parity.py +239 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_match_correlation.py +15 -5
- cbpr_validate-1.3.0/tests/test_profiles.py +382 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_report.py +12 -2
- cbpr_validate-1.3.0/tests/test_return_amounts.py +252 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_rules_address.py +2 -1
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_rules_returns.py +146 -111
- cbpr_validate-1.0.0/.claude/settings.local.json +0 -17
- cbpr_validate-1.0.0/src/cbpr_validate/model/finding.py +0 -21
- cbpr_validate-1.0.0/src/cbpr_validate/model/validation_result.py +0 -21
- cbpr_validate-1.0.0/src/cbpr_validate/rules/registry.py +0 -58
- cbpr_validate-1.0.0/src/cbpr_validate/rules/returns.py +0 -222
- cbpr_validate-1.0.0/tests/test_interface_parity.py +0 -133
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/.claude/settings.local.json.tmp.31316.7bec411697e7 +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/.github/workflows/ci.yml +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/.github/workflows/release.yml +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/api/__init__.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/codesets/__init__.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/codesets/loader.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/config.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/match/__init__.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/match/result.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/model/__init__.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/model/payment.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/parsers/__init__.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/parsers/_common.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/parsers/detect.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/parsers/pacs002.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/parsers/pacs004.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/parsers/pacs008.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/parsers/pacs009.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/parsers/parse.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/report/__init__.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/rules/__init__.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/rules/agents.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/rules/codes.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/rules/structural.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/schema/__init__.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/src/cbpr_validate/schema/xsd.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/__init__.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/fixtures/pacs008_valid_hybrid_ro.xml +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_addr004_country_codes.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_bicfi_agents.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_cod004_pacs002.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_golden_valid.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_misc_coverage.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_parsers.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_parsers_edgecases.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_parsers_phase4.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_phase3_rules.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_rules_agents.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_schema_xsd.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_smoke.py +0 -0
- {cbpr_validate-1.0.0 → cbpr_validate-1.3.0}/tests/test_str003_mandatory_amount.py +0 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
<!-- TODO: one or two sentences in your own voice. Suggested seed below — edit freely. -->
|
|
4
|
+
`cbpr-validate` validates ISO 20022 CBPR+ payment messages against the **usage
|
|
5
|
+
guidelines**, not just the XSD schema. This document explains how it is built and
|
|
6
|
+
why the key decisions were made — the schema tells you a message is *well-formed*;
|
|
7
|
+
this tool tells you whether it is *CBPR+-compliant*.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. The problem: XSD-valid ≠ CBPR+-compliant
|
|
12
|
+
|
|
13
|
+
<!-- TODO: 3–5 sentences. This is the thesis of the whole project — say it in your own words.
|
|
14
|
+
Points to hit:
|
|
15
|
+
- An XSD checks structure/data types. It passes messages that still violate CBPR+ usage rules.
|
|
16
|
+
- Concrete examples the tool catches that XSD cannot: unstructured-only postal address (invalid under SR2026),
|
|
17
|
+
the pacs.009 COV reimbursement-vs-intermediary agent distinction, cross-message drift between a pacs.004
|
|
18
|
+
return and the pacs.008 it reverses.
|
|
19
|
+
- Why this matters operationally: these gaps are what cause manual repair, reconciliation, and last-mile delay. -->
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Design goals
|
|
24
|
+
|
|
25
|
+
<!-- TODO: keep or trim. These are the principles the rest of the doc should visibly follow. -->
|
|
26
|
+
- **Traceable** — every finding carries a stable `rule_id`, a plain-English message, a field location, a
|
|
27
|
+
remediation hint, and a `spec_reference` back to the guideline.
|
|
28
|
+
- **Version-decoupled** — a rule is written once and runs against any supported message version, because rules
|
|
29
|
+
operate on an internal normalized model, not on raw XML.
|
|
30
|
+
- **One core, many interfaces** — library, CLI, and REST API all go through the same parse → validate → report
|
|
31
|
+
path, so they cannot disagree about what a message means.
|
|
32
|
+
- **Honest failure** — "we could not evaluate this message" is never reported as "this message is compliant."
|
|
33
|
+
- **No licensed material in the repo** — SWIFT XSDs and guideline text are never redistributed; rules are
|
|
34
|
+
implemented in code and cite their source.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 3. High-level architecture
|
|
39
|
+
|
|
40
|
+
A layered pipeline. Each stage is independently testable, and the internal model is the seam that decouples
|
|
41
|
+
everything downstream from message-version specifics.
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
┌─────────── interfaces ───────────┐
|
|
45
|
+
│ library (core.py) CLI REST API │
|
|
46
|
+
└─────────────────┬─────────────────┘
|
|
47
|
+
│ (one shared core) profile
|
|
48
|
+
│ │
|
|
49
|
+
raw bytes ──► detect ──► parse ──► normalized model ──► rules engine ──► severity ──► findings ──┐
|
|
50
|
+
(namespace) (per type) (Pydantic) correlation override ──► matches ─┤
|
|
51
|
+
(profiles) ▼
|
|
52
|
+
report: text / JSON / JUnit
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**The severity-override layer** sits between the rules engine and the reporters,
|
|
56
|
+
inside `rules/registry.run_all()` — the one place every interface reaches the
|
|
57
|
+
rules through. Rules emit their own declared severity and know nothing about
|
|
58
|
+
profiles; `profiles.apply_profile()` then rewrites the severities a profile
|
|
59
|
+
names, keeping the original in `Finding.base_severity`. Because this happens
|
|
60
|
+
before anything reads `ValidationResult.is_compliant`, a profile can change the
|
|
61
|
+
verdict and the exit code without any rule's detection logic changing. See
|
|
62
|
+
§4.3.
|
|
63
|
+
|
|
64
|
+
<!-- TODO: if you draw a nicer diagram later (e.g. a PNG or mermaid), drop it in here. Optional. -->
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 4. The layers
|
|
69
|
+
|
|
70
|
+
### 4.1 Detection & parsing (`parsers/`)
|
|
71
|
+
- `detect.py` identifies the message type by namespace (root element or child of a SWIFT envelope), covering
|
|
72
|
+
`pacs.008 / .009 / .002 / .004`.
|
|
73
|
+
- `parse.py` (`parse_message`) dispatches to the per-type parser; individual parsers
|
|
74
|
+
(`pacs008.py`, `pacs009.py`, `pacs002.py`, `pacs004.py`, shared `_common.py`) turn XML into the model.
|
|
75
|
+
- The pacs.009 COV parser captures the embedded `UndrlygCstmrCdtTrf` as a nested `Payment`, so the COV rule
|
|
76
|
+
and cross-message correlation can reach the underlying transaction.
|
|
77
|
+
|
|
78
|
+
### 4.2 Internal normalized model (`model/`)
|
|
79
|
+
- Pydantic v2 models — `Payment`, `Party`, `Agent`, `PostalAddress`, `Amount` — version-agnostic by design.
|
|
80
|
+
- `Finding` (with `Severity` = ERROR | WARN | INFO) and `ValidationResult` (`is_compliant`, `errors`,
|
|
81
|
+
`warnings`) are the output units for single-message validation.
|
|
82
|
+
- **This is the key architectural seam:** a `pacs.008.001.08` and its SR2026 variant both normalise to the
|
|
83
|
+
same shape, so every rule is written once. (See ADR-003.)
|
|
84
|
+
|
|
85
|
+
### 4.3 Rule engine (`rules/`)
|
|
86
|
+
- `registry.py` — decorator-based registration; `run_all()` executes every registered rule against a parsed
|
|
87
|
+
message and aggregates `Finding`s.
|
|
88
|
+
- Rule groups, each a module: `structural.py`, `address.py`, `codes.py`, `amounts.py`, `agents.py`,
|
|
89
|
+
`returns.py`.
|
|
90
|
+
- Rule ID families: `CBPR-STR-*`, `CBPR-ADDR-*`, `CBPR-COD-*`, `CBPR-AMT-*`, `CBPR-AGT-*`, `CBPR-RTN-*`.
|
|
91
|
+
- Headline rule: `CBPR-AGT-002` — the pacs.009 COV reimbursement-vs-intermediary agent distinction.
|
|
92
|
+
- Code-set checks (`codes.py`) validate against a committed, version-stamped snapshot of the ISO 20022
|
|
93
|
+
External Code Sets (`codesets/loader.py` + `codesets/data/`), so validation is reproducible offline.
|
|
94
|
+
|
|
95
|
+
**Severity profiles (`profiles.py`).** `run_all()` takes a keyword-only `profile` and applies it as the last
|
|
96
|
+
step, after every rule has run and before anything reads `is_compliant`. A profile is data — a flat
|
|
97
|
+
`rule_id -> severity` map — not branching inside a rule: `current` reports `CBPR-ADDR-001/002` as WARN
|
|
98
|
+
(what the network accepts today, SR2026 having been deferred with no new date), `sr2026` reports them as
|
|
99
|
+
ERROR. Rules emit their declared severity and never see the profile. An overridden finding keeps the rule's
|
|
100
|
+
severity in `Finding.base_severity`, so `severity != base_severity` identifies an SR2026 readiness gap, and
|
|
101
|
+
`ValidationResult.profile` records which rulebook produced the verdict.
|
|
102
|
+
|
|
103
|
+
This is deliberately the *only* override site. `run_all()` is the single point every interface reaches the
|
|
104
|
+
rules through — the library via `core.py`, the CLI's `check`, and the API's `/validate` — so no front door can
|
|
105
|
+
disagree with another about what a profile means. Applying a profile is idempotent: it compares against
|
|
106
|
+
`base_severity`, not the current severity.
|
|
107
|
+
|
|
108
|
+
### 4.4 Correlation engine (`match/`)
|
|
109
|
+
- Separate from rules because it evaluates a relationship **between two messages**, not a property of one.
|
|
110
|
+
- `correlate(a, b, direction=None)` infers the scenario from the message-type pair (either argument order):
|
|
111
|
+
- `CBPR-COR-001` pacs.009 COV ↔ originating pacs.008
|
|
112
|
+
- `CBPR-COR-002` pacs.002 ↔ pacs.008 (`direction` **required** — identity is never inferred from BICs)
|
|
113
|
+
- `CBPR-COR-003` pacs.004 return ↔ original pacs.008. Amount checks carry their own sub-ids (v1.3.0):
|
|
114
|
+
the echo `OrgnlIntrBkSttlmAmt` must equal the original (`-ECHO-MISMATCH` ERROR, `-ECHO-ABSENT` INFO); the
|
|
115
|
+
returned amount is graded against the actual original by `rules/_return_amounts.py`, shared with
|
|
116
|
+
`CBPR-RTN-003` (`-RETURNED-LOWER` INFO, `-RETURNED-HIGHER` WARN, `-FX` INFO).
|
|
117
|
+
- Primary match key is always **UETR**; `OrgnlTxId` / `OrgnlEndToEndId` are fallbacks only when a UETR is
|
|
118
|
+
absent, and the result flags that fallback. Two UETRs that *disagree* are a real non-match, never a reason
|
|
119
|
+
to try a weaker key.
|
|
120
|
+
- Output is `MatchResult` (distinct from `ValidationResult`; exposes `is_consistent`). (See ADR-005.)
|
|
121
|
+
- **v1 is deliberately pairwise and stateless** — you hand it the two messages to compare; there is no message
|
|
122
|
+
store. (See ADR-004.)
|
|
123
|
+
|
|
124
|
+
### 4.5 Reporting (`report/`)
|
|
125
|
+
- Three formatters — `text_report.py`, `json_report.py`, `junit_report.py` — all fed from the same result
|
|
126
|
+
objects.
|
|
127
|
+
- Only `ERROR` becomes a JUnit `<failure>`, so a CI build fails exactly when `is_compliant` / `is_consistent`
|
|
128
|
+
is false. All emitted text is ASCII and XML-escaped, so a non-Latin party name or an `&` in a field can
|
|
129
|
+
never corrupt or crash a report.
|
|
130
|
+
|
|
131
|
+
### 4.6 Optional XSD layer (`schema/xsd.py`)
|
|
132
|
+
- Off by default; enabled by pointing `CBPR_VALIDATE_XSD_DIR` at a **locally licensed** copy of the schemas.
|
|
133
|
+
- No schema is shipped or committed. If the layer is requested but a schema cannot be found, it raises rather
|
|
134
|
+
than returning "clean" — the caller asked for structural validation, so silently skipping it would be a lie.
|
|
135
|
+
|
|
136
|
+
### 4.7 Interfaces
|
|
137
|
+
- **Library** (`core.py`): `validate_file` / `validate_string` / `validate_bytes`. These **never raise** —
|
|
138
|
+
unreadable, malformed, and unrecognised inputs each return a `ValidationResult` carrying a single
|
|
139
|
+
`ORCH-READ-ERROR` / `ORCH-PARSE-ERROR` / `ORCH-UNSUPPORTED` finding, so a caller has exactly one shape to
|
|
140
|
+
handle. (See ADR-006.)
|
|
141
|
+
- **CLI** (`cli.py`, Typer): `validate`, `check`, `match`, `version`; `--format text|json|junit`,
|
|
142
|
+
`--fail-on error|warn|never`, `--xsd`/`--xsd-dir`, and `--direction` for a pacs.002 pair. Exit codes are a
|
|
143
|
+
stable contract: `0` clean, `1` findings at/above threshold (or a pair that does not correlate), `2`
|
|
144
|
+
unusable input.
|
|
145
|
+
- **REST API** (`api/main.py`, FastAPI): `POST /validate`, `POST /correlate`, `GET /health`, OpenAPI at
|
|
146
|
+
`/docs`. A correlation that fails is a `200` with `is_consistent: false` — a result, not an HTTP error; only
|
|
147
|
+
unusable input is a `400`.
|
|
148
|
+
- Parity is **tested, not asserted** (`tests/test_interface_parity.py`): library, CLI, and API outputs are
|
|
149
|
+
compared across the same messages and correlation scenarios.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 5. Error-handling philosophy
|
|
154
|
+
|
|
155
|
+
<!-- TODO: you can tighten this, but the substance is real and worth stating explicitly — it's a maturity signal. -->
|
|
156
|
+
- **"Cannot evaluate" ≠ "not compliant".** Orchestration failures use an `ORCH-` prefix and are kept distinct
|
|
157
|
+
from usage-guideline violations.
|
|
158
|
+
- **The library core never raises.** Every failure mode returns a `ValidationResult`, so callers integrate one
|
|
159
|
+
contract.
|
|
160
|
+
- **Exit codes are an API.** The CLI's `0 / 1 / 2` contract is what lets the tool act as a CI gate.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 6. Key design decisions (ADRs)
|
|
165
|
+
|
|
166
|
+
<!-- TODO: write these up as short ADRs under docs/adr/ (context → decision → consequences, ~1 page each).
|
|
167
|
+
This section is just the index. The four marked ★ are the ones the build plan told you not to skip. -->
|
|
168
|
+
- **ADR-001 ★** — Rules in code, not a rules DSL.
|
|
169
|
+
- **ADR-002 ★** — Do not ship SWIFT XSDs; cite sources, let users supply their own licensed copy.
|
|
170
|
+
- **ADR-003 ★** — An internal normalized (Pydantic) model to decouple rules from message version.
|
|
171
|
+
- **ADR-004 ★** — Correlation is pairwise/stateless in v1, not a stored ledger.
|
|
172
|
+
- **ADR-005** — `MatchResult` is a distinct type from `ValidationResult` (relationship vs. property).
|
|
173
|
+
- **ADR-006** — The library core never raises; orchestration errors are findings with an `ORCH-` prefix.
|
|
174
|
+
- **ADR-007** — Severity profiles are data applied once in `run_all()`, not conditionals inside rules; `current`
|
|
175
|
+
is the default because SR2026 was deferred with no confirmed date.
|
|
176
|
+
- **ADR-008** — A bad *profile name* raises (CLI exit 2 / API 422) even though a bad *document* does not:
|
|
177
|
+
silently judging against an unintended rulebook is worse than failing loudly.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## 7. Extensibility — how to add a rule
|
|
182
|
+
|
|
183
|
+
<!-- TODO: verify the exact function signature against rules/registry.py before publishing. Seed: -->
|
|
184
|
+
1. Add a function to the relevant `rules/<group>.py`, register it with the registry decorator.
|
|
185
|
+
2. Return `Finding`s with a stable `rule_id`, a `severity`, a `location`, a `remediation`, and a
|
|
186
|
+
`spec_reference` citing the guideline.
|
|
187
|
+
3. Add adversarial fixtures (a message that should fire it and one that should not) under `tests/`.
|
|
188
|
+
4. `run_all()` picks it up automatically — no interface change needed.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 8. Testing strategy
|
|
193
|
+
|
|
194
|
+
- **192 tests, 99% coverage**, `ruff` and `mypy` clean. <!-- TODO: update these numbers when they change. -->
|
|
195
|
+
- **Adversarial fixtures**: every rule has both a clean case and a deliberately broken one (wrong UETR, amount
|
|
196
|
+
drift, currency/party drift, mis-echoed references, missing mandatory fields).
|
|
197
|
+
- **Interface parity tests** guarantee library / CLI / API cannot silently diverge.
|
|
198
|
+
- CI (`.github/workflows/ci.yml`) gates lint, type-check, and tests on every change.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 9. Scope & non-goals (v1)
|
|
203
|
+
|
|
204
|
+
**In scope:** `pacs.008`, `pacs.009` (core + COV), `pacs.002`, `pacs.004`; usage-guideline rules; External
|
|
205
|
+
Code Set checks; pairwise cross-message correlation; text/JSON/JUnit output.
|
|
206
|
+
|
|
207
|
+
**Out of scope (v1):** camt.05x / camt.110-111 (E&I); message *generation*; a stateful message store /
|
|
208
|
+
live-stream correlation; network/transport; redistribution of licensed schemas; proprietary regional schemes.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 10. Performance
|
|
213
|
+
|
|
214
|
+
<!-- TODO: this is the one number you still owe the README/architecture doc. Run a quick benchmark
|
|
215
|
+
(N messages through validate_bytes in a loop, wall-clock) and state throughput here, e.g. "~X messages/sec
|
|
216
|
+
single-threaded on <machine>". It's a small task that signals you thought about scale. -->
|
|
217
|
+
_Benchmark: TODO._
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 11. Roadmap (v2)
|
|
222
|
+
|
|
223
|
+
camt.053/054 and camt.110/111 (E&I) · a hosted web playground · a reusable GitHub Action (CI step) · message
|
|
224
|
+
generation (pairs with the agentic project) · pluggable rule packs (HVPS+, regional) · a stateful
|
|
225
|
+
`MessageStore` so messages can be ingested one at a time (`ingest`) and correlations queried later (`query
|
|
226
|
+
--uetr ...`) instead of always pairwise.
|
|
@@ -144,8 +144,13 @@ Implement each as a registered rule with a stable ID. Group + severity below. **
|
|
|
144
144
|
- `CBPR-STR-004` Settlement method / clearing system consistency — WARN
|
|
145
145
|
|
|
146
146
|
**Address / SR2026 (`address.py`)** — the headline group
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
|
|
148
|
+
> **Severity is profile-dependent as of v1.2.0.** SWIFT deferred the SR2026 payments changes and no new date
|
|
149
|
+
> is confirmed, so `ADDR-001` and `ADDR-002` are **WARN** under the default `current` profile and **ERROR**
|
|
150
|
+
> under `sr2026`. The severities below are the `sr2026` (strict) reading. See `profiles.py`.
|
|
151
|
+
|
|
152
|
+
- `CBPR-ADDR-001` Unstructured-only address (AdrLine, no TwnNm/Ctry) — ERROR under `sr2026`, WARN under `current`
|
|
153
|
+
- `CBPR-ADDR-002` Minimum gate: structured TwnNm **and** Ctry present — ERROR under `sr2026`, WARN under `current`
|
|
149
154
|
- `CBPR-ADDR-003` Hybrid address line-count within cap *(verify exact cap)* — WARN
|
|
150
155
|
- `CBPR-ADDR-004` Ctry is ISO 3166-1 alpha-2 — ERROR
|
|
151
156
|
- `CBPR-ADDR-005` Classify & report: fully-structured / hybrid / unstructured — INFO
|
|
@@ -171,8 +176,8 @@ Implement each as a registered rule with a stable ID. Group + severity below. **
|
|
|
171
176
|
**Returns (`returns.py`)** — pacs.004 usage rules
|
|
172
177
|
- `CBPR-RTN-001` Return reason code ∈ ExternalReturnReason1Code — ERROR
|
|
173
178
|
- `CBPR-RTN-002` Mandatory original-reference fields present (OrgnlMsgId, OrgnlEndToEndId, OrgnlTxId, OrgnlUETR, OrgnlInterbankSettlementAmt, OrgnlInterbankSettlementDt) — ERROR
|
|
174
|
-
- `CBPR-RTN-003
|
|
175
|
-
-
|
|
179
|
+
- `CBPR-RTN-003-*` Returned interbank settlement amount vs the original amount the return quotes *(SME rules, v1.3.0)*: `-RETURNED-LOWER` charges deducted, states whether `ChrgsInf` reconciles — INFO; `-RETURNED-HIGHER` same-currency over-return — WARN; `-FX` different currencies — INFO
|
|
180
|
+
- ~~`CBPR-RTN-004`~~ Retired in v1.3.0 (reconciliation is stated inside `CBPR-RTN-003-RETURNED-LOWER`); id reserved
|
|
176
181
|
- `CBPR-RTN-005` Compensation/interest fields, if present, well-formed — INFO
|
|
177
182
|
|
|
178
183
|
---
|
|
@@ -185,7 +190,7 @@ Primary match key is always **UETR** (CBPR+ mandates it persist end-to-end acros
|
|
|
185
190
|
|
|
186
191
|
- `CBPR-COR-001` **pacs.009 COV ↔ originating pacs.008** — match `UndrlygCstmrCdtTrf.PmtId.UETR` (in the COV's embedded underlying transaction) against the originating `pacs.008`'s `PmtId.UETR`. On match, cross-check settlement amount/currency and Dbtr/Cdtr consistency between the two.
|
|
187
192
|
- `CBPR-COR-002` **pacs.002 ↔ pacs.008 (bidirectional)** — match `TxInfAndSts.OrgnlUETR` (falling back to `OrgnlTxId`/`OrgnlEndToEndId`) against the `pacs.008`'s `PmtId`. Direction (was the `pacs.008` sent by you or received by you) is passed explicitly via a `direction: outbound|inbound` parameter — the tool does not infer identity from BICs; see CLI below.
|
|
188
|
-
- `CBPR-COR-003` **pacs.004 return ↔ original pacs.008** — match `OrgnlGrpInf`/`TxInf.OrgnlUETR` against the original `pacs.008`'s `PmtId.UETR`. On match,
|
|
193
|
+
- `CBPR-COR-003` **pacs.004 return ↔ original pacs.008** — match `OrgnlGrpInf`/`TxInf.OrgnlUETR` against the original `pacs.008`'s `PmtId.UETR`. On match, check the echo `OrgnlIntrBkSttlmAmt` equals the original exactly (`-ECHO-MISMATCH` ERROR, `-ECHO-ABSENT` INFO) and grade the returned amount against the actual original (`-RETURNED-LOWER` INFO, `-RETURNED-HIGHER` WARN, `-FX` INFO) - see v1.3.0 below.
|
|
189
194
|
|
|
190
195
|
**Interface shape (Phase 5):**
|
|
191
196
|
```
|
|
@@ -451,6 +456,22 @@ Dockerfile, mkdocs site, README polish, badges, benchmark, TestPyPI → PyPI, ta
|
|
|
451
456
|
|
|
452
457
|
---
|
|
453
458
|
|
|
459
|
+
### Post-v1 increments (outside the original phase plan)
|
|
460
|
+
|
|
461
|
+
- **v1.1.0** — `CBPR-ADDR-006` (AdrLine length/count), ISO 4217 currency validation fix, `ARCHITECTURE.md`.
|
|
462
|
+
- **v1.2.0** — **Severity profiles** (`current` / `sr2026`), in response to SWIFT deferring the SR2026
|
|
463
|
+
payments changes. Behaviour change: unstructured addresses are WARN by default. Adds `--profile` to the CLI,
|
|
464
|
+
`profile=` to the library, a `profile` field to `POST /validate`, `Finding.base_severity`, and the profile in
|
|
465
|
+
all three reporters. `--fail-on` now accepts `warn` and `warning` on both commands.
|
|
466
|
+
Deferred work is logged in `KNOWN_ISSUES.md`.
|
|
467
|
+
- **v1.3.0** — **Return amount rules** (SME-specified). A lower returned amount is the normal
|
|
468
|
+
charges-deducted return, not a mismatch; the original-amount echo is now checked. `CBPR-COR-003` amount checks
|
|
469
|
+
split into `-ECHO-MISMATCH` (ERROR), `-ECHO-ABSENT`, `-RETURNED-LOWER`, `-FX` (INFO) and `-RETURNED-HIGHER`
|
|
470
|
+
(WARN); `CBPR-RTN-003` aligned to the same grading via the shared `rules/_return_amounts.py`; `CBPR-RTN-004`
|
|
471
|
+
retired. Behaviour change - see `CHANGELOG.md`.
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
454
475
|
## 11. Senior-signal artifacts (do not skip)
|
|
455
476
|
|
|
456
477
|
These convert "a repo" into "an architect's portfolio":
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. This project adheres
|
|
4
|
+
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
+
|
|
6
|
+
## [1.3.0] - Unreleased
|
|
7
|
+
|
|
8
|
+
### Changed - BEHAVIOUR CHANGE, please read
|
|
9
|
+
|
|
10
|
+
**A lower returned amount is no longer a mismatch; the original-amount echo is
|
|
11
|
+
now checked.** Banks normally deduct their charges from a returned payment, so
|
|
12
|
+
a pacs.004 that returns less than the original is the normal case, not drift.
|
|
13
|
+
What must match exactly is the return's echo of the original
|
|
14
|
+
(`OrgnlIntrBkSttlmAmt`).
|
|
15
|
+
|
|
16
|
+
Correlation (`pacs.004 <-> pacs.008`, `match` / `/correlate` / `correlate()`):
|
|
17
|
+
the amount checks are split out of `CBPR-COR-003` into stable sub-ids.
|
|
18
|
+
|
|
19
|
+
| Case | Rule id | Before 1.3.0 | From 1.3.0 |
|
|
20
|
+
| --- | --- | --- | --- |
|
|
21
|
+
| Echo differs from the original amount or currency | `CBPR-COR-003-ECHO-MISMATCH` | ERROR (as `CBPR-COR-003`) | ERROR |
|
|
22
|
+
| Echo absent | `CBPR-COR-003-ECHO-ABSENT` | nothing | INFO |
|
|
23
|
+
| Same currency, returned lower | `CBPR-COR-003-RETURNED-LOWER` | nothing | INFO, says whether ChrgsInf reconciles |
|
|
24
|
+
| Same currency, returned higher | `CBPR-COR-003-RETURNED-HIGHER` | ERROR (as `CBPR-COR-003`) | **WARN** |
|
|
25
|
+
| Returned currency differs (FX return) | `CBPR-COR-003-FX` | nothing | INFO |
|
|
26
|
+
|
|
27
|
+
`is_consistent` is still false only when there is an ERROR. **A same-currency
|
|
28
|
+
over-return no longer makes a pair inconsistent, and `cbpr-validate match` exits
|
|
29
|
+
`0` for it instead of `1`.** A broken link and mis-echoed references are still
|
|
30
|
+
reported as `CBPR-COR-003`.
|
|
31
|
+
|
|
32
|
+
Single-message validation of a pacs.004 (`validate` / `check` / `/validate`):
|
|
33
|
+
`CBPR-RTN-003` now grades the returned amount the same way, against the
|
|
34
|
+
original amount the return quotes.
|
|
35
|
+
|
|
36
|
+
| Case | Before 1.3.0 | From 1.3.0 |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| Returned currency differs from the quoted original | `CBPR-RTN-003` ERROR | `CBPR-RTN-003-FX` INFO |
|
|
39
|
+
| Same currency, returned higher | `CBPR-RTN-003` ERROR | `CBPR-RTN-003-RETURNED-HIGHER` WARN |
|
|
40
|
+
| Same currency, returned lower, not explained by ChrgsInf | `CBPR-RTN-003` WARN | `CBPR-RTN-003-RETURNED-LOWER` INFO |
|
|
41
|
+
| Same currency, returned lower, explained by ChrgsInf | nothing | `CBPR-RTN-003-RETURNED-LOWER` INFO |
|
|
42
|
+
|
|
43
|
+
**An FX or over-returned pacs.004 that was `NOT COMPLIANT` in 1.2.0 may now be
|
|
44
|
+
`COMPLIANT`, and a CLI call that exited `1` may now exit `0`.** A run with
|
|
45
|
+
`--fail-on warning` still fails on an over-return.
|
|
46
|
+
|
|
47
|
+
### Removed
|
|
48
|
+
|
|
49
|
+
- `CBPR-RTN-004` (ChrgsInf does not reconcile, WARN) is retired and its id is
|
|
50
|
+
reserved. Whether returned + charges reconciles is now stated inside the
|
|
51
|
+
`RETURNED-LOWER` INFO finding, with the difference when it does not.
|
|
52
|
+
|
|
53
|
+
### Notes
|
|
54
|
+
|
|
55
|
+
- Only charges in the returned currency are added up when reconciling;
|
|
56
|
+
charges in another currency are counted and mentioned, not converted.
|
|
57
|
+
- All amount arithmetic is `Decimal`.
|
|
58
|
+
- COV (`CBPR-COR-001`) and pacs.002 (`CBPR-COR-002`) correlation are unchanged.
|
|
59
|
+
|
|
60
|
+
## [1.2.0] - 2026-10-12
|
|
61
|
+
|
|
62
|
+
### Changed — BEHAVIOUR CHANGE, please read
|
|
63
|
+
|
|
64
|
+
**Unstructured postal addresses are now reported as `WARN`, not `ERROR`, by
|
|
65
|
+
default. A message that was `NOT COMPLIANT` in 1.1.0 may now be `COMPLIANT`,
|
|
66
|
+
and a CLI call that exited `1` may now exit `0`.**
|
|
67
|
+
|
|
68
|
+
`CBPR-ADDR-001` (unstructured-only address) and `CBPR-ADDR-002` (TownName and
|
|
69
|
+
Country required) are the two affected rules. Nothing else changed severity.
|
|
70
|
+
|
|
71
|
+
**To restore the previous strict behaviour, select the `sr2026` profile:**
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
cbpr-validate validate payment.xml --profile sr2026 # exits 1, as 1.1.0 did
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
validate_file("payment.xml", profile="sr2026") # is_compliant False, as 1.1.0
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
curl -d '{"message": "...", "profile": "sr2026"}' localhost:8000/validate
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Alternatively keep the default profile and tighten the gate instead, which
|
|
86
|
+
fails the build on the readiness gap while still reporting it as a warning:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
cbpr-validate validate payment.xml --fail-on warn # exits 1 on a WARN
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Why.** SWIFT deferred every payments change in Standards Release 2026,
|
|
93
|
+
including the removal of fully unstructured postal addresses in CBPR+
|
|
94
|
+
(originally 14 Nov 2026). **A new date has not been confirmed.** The network
|
|
95
|
+
accepts these addresses today, so reporting them as hard errors overstated the
|
|
96
|
+
position: it told users their live, working traffic was non-compliant. They are
|
|
97
|
+
now a visible readiness gap by default, and a rejection only when you ask for
|
|
98
|
+
the future rulebook.
|
|
99
|
+
|
|
100
|
+
### Added
|
|
101
|
+
|
|
102
|
+
- **Severity profiles.** `current` (the new default) and `sr2026`. A profile is
|
|
103
|
+
a flat `rule_id -> severity` mapping applied once after the rules run; no
|
|
104
|
+
rule's detection logic is profile-aware.
|
|
105
|
+
- CLI: `--profile current|sr2026` on `validate` and `check`.
|
|
106
|
+
- Library: `profile=` on `validate_file`, `validate_string`, `validate_bytes`
|
|
107
|
+
and `rules.registry.run_all`.
|
|
108
|
+
- API: optional `"profile"` field on `POST /validate`.
|
|
109
|
+
- An unknown profile name is an input error: CLI exit `2` (listing the valid
|
|
110
|
+
names), API `422`, `ValueError` from the library.
|
|
111
|
+
- **`Finding.base_severity`** — the severity the rule itself declared, always
|
|
112
|
+
populated. `severity != base_severity` means the active profile moved that
|
|
113
|
+
finding, i.e. it is an SR2026 readiness gap.
|
|
114
|
+
- **`ValidationResult.profile`** records which rulebook produced the verdict,
|
|
115
|
+
and `.overridden` lists the findings the profile moved.
|
|
116
|
+
- The profile is surfaced by every reporter: a `(profile: ...)` suffix on the
|
|
117
|
+
text summary (plus an `N SR2026 address gaps` note when any fired), a
|
|
118
|
+
top-level `"profile"` field in JSON, and a `<property name="profile">` in
|
|
119
|
+
JUnit.
|
|
120
|
+
- `--fail-on` now accepts both `warn` and `warning` on **both** `validate` and
|
|
121
|
+
`check`. Previously `check` accepted only `warn` and `validate` only
|
|
122
|
+
`warning`, and the other spelling exited `2`. Both old spellings still work.
|
|
123
|
+
|
|
124
|
+
### Notes
|
|
125
|
+
|
|
126
|
+
- JUnit still maps only `ERROR` to `<failure>`, so under the default profile an
|
|
127
|
+
address gap no longer fails a build. Use `--profile sr2026` or
|
|
128
|
+
`--fail-on warn` if you want it to.
|
|
129
|
+
- No new dependencies. No rule's detection logic changed.
|
|
130
|
+
|
|
131
|
+
## [1.1.0] - 2026-09-27
|
|
132
|
+
|
|
133
|
+
### Added
|
|
134
|
+
|
|
135
|
+
- `CBPR-ADDR-006` — `AdrLine` length and count validation (`Max70Text`,
|
|
136
|
+
`maxOccurs=7`).
|
|
137
|
+
- `ARCHITECTURE.md`.
|
|
138
|
+
|
|
139
|
+
### Fixed
|
|
140
|
+
|
|
141
|
+
- `CBPR-AMT-001/002` — currency validated against the full ISO 4217 list, with
|
|
142
|
+
decimal-place checking separated from validity.
|
|
143
|
+
|
|
144
|
+
## [1.0.0] - 2026-09
|
|
145
|
+
|
|
146
|
+
### Added
|
|
147
|
+
|
|
148
|
+
- Initial release: version-agnostic payment model; `pacs.008`, `pacs.009`
|
|
149
|
+
(core + COV), `pacs.002` and `pacs.004` parsers; the structural, address,
|
|
150
|
+
code-set, amount, agent and return rule groups; pairwise correlation
|
|
151
|
+
(`CBPR-COR-001/002/003`); the Typer CLI, FastAPI service and text/JSON/JUnit
|
|
152
|
+
reporters; and the optional XSD layer.
|
|
@@ -38,6 +38,20 @@ TestPyPI -> PyPI, tag v1.0.0).
|
|
|
38
38
|
- `CBPR-ADDR-003` (hybrid line-count cap) is **intentionally unregistered** —
|
|
39
39
|
the cap is ambiguous in available guideline material and we refuse to guess.
|
|
40
40
|
Leave it unregistered until the cap is confirmed.
|
|
41
|
+
- **Severity profiles** (v1.2.0): `current` is the DEFAULT and reports
|
|
42
|
+
`CBPR-ADDR-001/002` as WARN; `sr2026` reports them as ERROR. This is because
|
|
43
|
+
SWIFT deferred the SR2026 payments changes with no confirmed new date. Do not
|
|
44
|
+
"fix" the default back to ERROR — a message the network accepts today must
|
|
45
|
+
not be reported as non-compliant. Profiles are data in `profiles.py` applied
|
|
46
|
+
ONCE at the end of `rules/registry.run_all()`; never add profile conditionals
|
|
47
|
+
inside a rule. `sr2026` restates the address severities explicitly rather
|
|
48
|
+
than inheriting them, on purpose.
|
|
49
|
+
- `Finding.base_severity` is **always populated** (defaulted from `severity` by
|
|
50
|
+
a pre-validator, so rules keep passing only `severity=`). It is not optional;
|
|
51
|
+
`severity != base_severity` is the signal that a profile moved a finding.
|
|
52
|
+
- `--fail-on` accepts BOTH `warn` and `warning` on both `validate` and `check`.
|
|
53
|
+
They used to disagree (`check` took `warn`, `validate` took `warning`); both
|
|
54
|
+
spellings now work on both and must keep working.
|
|
41
55
|
- `CBPR-COD-004` now runs against a real parsed `pacs.002`; the Phase 3
|
|
42
56
|
direct-construction workaround was removed in Phase 4. Done — don't revisit.
|
|
43
57
|
- Correlation returns `MatchResult`, **not** `ValidationResult`, and lives
|
|
@@ -52,6 +66,11 @@ TestPyPI -> PyPI, tag v1.0.0).
|
|
|
52
66
|
- The three interfaces share `parsers/parse.py`, `rules/registry.run_all` and
|
|
53
67
|
`report/json_report`. Never reimplement parsing or formatting inside `cli.py`
|
|
54
68
|
or `api/main.py` — `tests/test_interface_parity.py` will fail if you do.
|
|
69
|
+
- **Return amount rules** (v1.3.0) are SME decisions: a lower returned amount is the
|
|
70
|
+
normal charges-deducted return (INFO, never a mismatch); only the echo
|
|
71
|
+
`OrgnlIntrBkSttlmAmt` must match the original exactly (ERROR). Over-return in
|
|
72
|
+
the same currency is WARN, a currency difference is an FX return (INFO).
|
|
73
|
+
`CBPR-RTN-004` is retired, its id reserved. Do not re-tighten these.
|
|
55
74
|
- JUnit maps **only** ERROR to `<failure>`. WARN/INFO are passing cases, so a
|
|
56
75
|
build fails exactly when the message is non-compliant.
|
|
57
76
|
|
|
@@ -79,7 +98,9 @@ TestPyPI -> PyPI, tag v1.0.0).
|
|
|
79
98
|
Phase 5 ONLY. If you catch yourself cross-referencing two messages or
|
|
80
99
|
building an interface before then, stop — it's the next phase.
|
|
81
100
|
7. **Stay in scope for the current phase.** If you find an out-of-scope gap,
|
|
82
|
-
log it in `KNOWN_ISSUES.md` rather than expanding scope.
|
|
101
|
+
log it in `KNOWN_ISSUES.md` rather than expanding scope. That file exists as
|
|
102
|
+
of v1.2.0 and already records the batch/folder summary, TOML config
|
|
103
|
+
overrides, the `check`-bypasses-`core` divergence, and `CBPR-ADDR-003`.
|
|
83
104
|
8. **Definition of done for any phase:** all listed rules implemented AND
|
|
84
105
|
registered; adversarial tests present; `pytest` green; coverage ≥ 90% on
|
|
85
106
|
new modules; ruff + mypy clean; README + BUILD_PLAN updated; one commit.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Known issues and deferred work
|
|
2
|
+
|
|
3
|
+
Gaps found while building a phase that were deliberately left out of scope
|
|
4
|
+
rather than silently expanded into it (CLAUDE.md operating rule 7). Each entry
|
|
5
|
+
says what it is, why it was deferred, and what it would take.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. No batch / folder readiness summary
|
|
10
|
+
|
|
11
|
+
**What.** There is no way to point the tool at a directory of messages and get
|
|
12
|
+
an aggregate readiness report ("412 messages, 38 with SR2026 address gaps,
|
|
13
|
+
across 6 debtor BICs"). Today you validate one message per invocation and
|
|
14
|
+
aggregate the JSON yourself.
|
|
15
|
+
|
|
16
|
+
**Why deferred.** Out of scope for the severity-profiles change, which is about
|
|
17
|
+
*which rulebook* a single message is judged against. Batch reporting is a
|
|
18
|
+
separate concern with its own design questions — output shape, grouping keys,
|
|
19
|
+
memory behaviour on large folders, partial-failure semantics — and bolting a
|
|
20
|
+
loop onto the CLI would pre-empt those choices badly.
|
|
21
|
+
|
|
22
|
+
**What it would take.** A new `cbpr-validate scan <dir>` command, an aggregate
|
|
23
|
+
result type (counts and groupings, not a concatenated `ValidationResult`), and
|
|
24
|
+
a reporter for it. The per-message path needs no changes.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. No TOML config overrides
|
|
29
|
+
|
|
30
|
+
**What.** Profiles are the only way to change a severity, and the profile table
|
|
31
|
+
is in code (`src/cbpr_validate/profiles.py`). A bank cannot supply its own
|
|
32
|
+
`cbpr-validate.toml` declaring, say, that `CBPR-RTN-004` is an ERROR in their
|
|
33
|
+
environment.
|
|
34
|
+
|
|
35
|
+
**Why deferred.** Deliberate for now. A committed profile table is auditable
|
|
36
|
+
and reproducible: a finding's severity is a property of the released version,
|
|
37
|
+
not of whatever file happened to be on the machine. User-supplied overrides
|
|
38
|
+
need answers on precedence, validation of unknown rule IDs, and provenance in
|
|
39
|
+
the report (a result would have to record *which* config produced it) before
|
|
40
|
+
they are safe to add.
|
|
41
|
+
|
|
42
|
+
**What it would take.** A loader producing the same `rule_id -> severity`
|
|
43
|
+
mapping shape `profiles.py` already uses, layered over the selected profile,
|
|
44
|
+
plus provenance recorded on `ValidationResult` so a report can say where a
|
|
45
|
+
severity came from. The override mechanism itself would not change.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 3. `check` bypasses `core`, so there are two roads to the rules
|
|
50
|
+
|
|
51
|
+
**What.** The documented design is "one shared core", but two different paths
|
|
52
|
+
exist:
|
|
53
|
+
|
|
54
|
+
| | Road A | Road B |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| Used by | library `validate_*`, CLI `validate` | CLI `check`, API `POST /validate` |
|
|
57
|
+
| Entry | `core.validate_bytes` | caller reads and parses for itself |
|
|
58
|
+
| Bad input | an `ORCH-*` ERROR finding, never raises | CLI exit 2 / HTTP 400 |
|
|
59
|
+
|
|
60
|
+
So `check` and the API do not get `core`'s no-raise orchestration contract, and
|
|
61
|
+
error handling for an unreadable or unrecognised document differs between
|
|
62
|
+
`validate` and `check`.
|
|
63
|
+
|
|
64
|
+
**Why deferred.** Unifying them is a refactor of the CLI and API error paths
|
|
65
|
+
with its own behaviour changes (exit codes and HTTP statuses would move for
|
|
66
|
+
malformed input), and it is unrelated to severity profiles. It was safe to
|
|
67
|
+
leave alone here because the profile override lives in
|
|
68
|
+
`rules.registry.run_all()` — the one function *both* roads pass through — so
|
|
69
|
+
every interface already agrees on what a profile means.
|
|
70
|
+
|
|
71
|
+
**Guard in place.** `tests/test_interface_parity.py::test_check_and_validate_agree_on_the_verdict`
|
|
72
|
+
pins that `check` and `validate` return the same verdict and the same JSON for
|
|
73
|
+
the same profile, so the divergence cannot quietly widen while it remains.
|
|
74
|
+
|
|
75
|
+
**What it would take.** Route `check` and the API through `core.validate_bytes`,
|
|
76
|
+
then decide deliberately whether a malformed document should be an `ORCH-*`
|
|
77
|
+
finding (exit 1) or an input error (exit 2) — and change the documented exit-code
|
|
78
|
+
contract to match whichever is chosen.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 4. `CBPR-ADDR-003` is unregistered
|
|
83
|
+
|
|
84
|
+
**What.** The hybrid-address line-count cap is implemented nowhere; the rule ID
|
|
85
|
+
is reserved and the function is not registered.
|
|
86
|
+
|
|
87
|
+
**Why deferred.** The cap value is ambiguous in the public CBPR+ guideline
|
|
88
|
+
material available, and guessing a threshold would produce confident-looking
|
|
89
|
+
wrong findings (CLAUDE.md operating rule 3). Note this is distinct from
|
|
90
|
+
`CBPR-ADDR-006`, which enforces the two caps that *are* unambiguous because
|
|
91
|
+
they come from the ISO 20022 schema itself (`Max70Text`, `maxOccurs=7`).
|
|
92
|
+
|
|
93
|
+
**What it would take.** Confirmation of the cap from the usage guidelines, then
|
|
94
|
+
a registered rule plus a passing and an adversarial fixture.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 5. Return charges in another currency are not converted
|
|
99
|
+
|
|
100
|
+
**What.** When `CBPR-COR-003-RETURNED-LOWER` / `CBPR-RTN-003-RETURNED-LOWER`
|
|
101
|
+
reconcile returned + ChrgsInf against the original, only charges in the
|
|
102
|
+
returned currency are added up. A charge in another currency is counted and
|
|
103
|
+
mentioned in the message ("1 charge(s) in other currencies not included"), not
|
|
104
|
+
converted.
|
|
105
|
+
|
|
106
|
+
**Why deferred.** Converting would need an FX rate the message does not carry,
|
|
107
|
+
and the reconciliation is INFO either way (v1.3.0 return amount rules), so no
|
|
108
|
+
verdict depends on it.
|
|
109
|
+
|
|
110
|
+
**What it would take.** A rate source (or the rate from the message's own
|
|
111
|
+
`XchgRate`, where present) and a decision on rounding tolerance - which falls
|
|
112
|
+
under CLAUDE.md operating rule 3 and needs SME confirmation first.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 6. `ExternalReturnReason1Code` snapshot is incomplete
|
|
117
|
+
|
|
118
|
+
**What.** `codesets/data/iso20022_codesets.json` holds only `CURR`, `DNCL` and
|
|
119
|
+
`CANC` for `ExternalReturnReason1Code`. Common real codes such as `AC01`,
|
|
120
|
+
`AC04`, `AM05` and `MD06` therefore fail `CBPR-RTN-001` (ERROR).
|
|
121
|
+
|
|
122
|
+
**Why deferred.** Found while building synthetic returns for the v1.3.0 amount
|
|
123
|
+
rules; refreshing a code-set snapshot is a separate, data-only change.
|
|
124
|
+
|
|
125
|
+
**What it would take.** Regenerate the snapshot from the published ISO 20022
|
|
126
|
+
External Code Sets and add passing fixtures for a few common return codes.
|