mnemopay 1.0.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.
mnemopay-1.0.0/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 J&B Enterprise LLC
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
mnemopay-1.0.0/NOTICE ADDED
@@ -0,0 +1,70 @@
1
+ MnemoPay Python SDK
2
+ Copyright (c) 2026 Jeremiah Omiagbo / J&B Enterprise LLC. All rights reserved.
3
+
4
+ Original author: Jeremiah Omiagbo (jeremiah@getbizsuite.com)
5
+ First published: April 2026 (PyPI: mnemopay v1.0.0b1)
6
+ GitHub: https://github.com/mnemopay/mnemopay-python
7
+
8
+ This software is licensed under the Apache License, Version 2.0
9
+ (see LICENSE file).
10
+
11
+ ══════════════════════════════════════════════════════════════════════════
12
+ LICENSE HISTORY — VERSION SPLIT
13
+ ══════════════════════════════════════════════════════════════════════════
14
+
15
+ v1.0.0b1, v1.0.0b2, v1.0.0b3, v1.0.0b4 MIT License
16
+ v1.0.0 and later Apache License 2.0
17
+
18
+ The four pre-release betas (`1.0.0b1` through `1.0.0b4`, published April
19
+ through May 2026) are permanently licensed under the MIT License and
20
+ remain available under those terms on PyPI. The first stable release
21
+ (`v1.0.0`) and all subsequent versions are licensed under the Apache
22
+ License 2.0.
23
+
24
+ Reason for the relicense at the stable cut: alignment with the canonical
25
+ TypeScript SDK at https://www.npmjs.com/package/@mnemopay/sdk (Apache 2.0),
26
+ plus the patent grant + retaliation clause Apache 2.0 provides for
27
+ enterprise embedders. If you depend on the MIT terms specifically, pin to
28
+ `mnemopay==1.0.0b4` — that version stays MIT in perpetuity.
29
+
30
+ ══════════════════════════════════════════════════════════════════════════
31
+ PRIOR ART CHAIN
32
+ ══════════════════════════════════════════════════════════════════════════
33
+
34
+ - 2026-04-xx: v1.0.0b1 published to PyPI (MIT, timestamped, immutable)
35
+ - 2026-04-xx: v1.0.0b2 published to PyPI (MIT)
36
+ - 2026-04-xx: v1.0.0b3 published to PyPI (MIT)
37
+ - 2026-05-xx: v1.0.0b4 published to PyPI (MIT) — last MIT release
38
+ - 2026-xx-xx: v1.0.0 published to PyPI (Apache 2.0) — first stable
39
+
40
+ ══════════════════════════════════════════════════════════════════════════
41
+ ORIGINAL INVENTIONS DOCUMENTED HEREIN
42
+ ══════════════════════════════════════════════════════════════════════════
43
+
44
+ These inventions also appear in the canonical TypeScript SDK; the
45
+ Python port mirrors the spec.
46
+
47
+ 1. Memory-Payment Feedback Loop — payment settlements reinforce the
48
+ memories that led to the decision (Hebbian learning applied to agent
49
+ economics).
50
+ 2. Agent Credit Score — reputation computed from settlement history,
51
+ memory quality, dispute rate, and behavioral patterns (formerly
52
+ "Agent FICO"; renamed to avoid implied association with Fair Isaac
53
+ Corporation).
54
+ 3. Adaptive Engine — self-optimizing fee rates, risk thresholds, and
55
+ policy parameters that learn from settlement and dispute outcomes.
56
+
57
+ ══════════════════════════════════════════════════════════════════════════
58
+ TRADEMARK
59
+ ══════════════════════════════════════════════════════════════════════════
60
+
61
+ "MnemoPay" is a trademark of J&B Enterprise LLC. Use of the name in
62
+ forks, redistributions, or derivative works requires explicit permission
63
+ under Apache 2.0 Section 6.
64
+
65
+ ══════════════════════════════════════════════════════════════════════════
66
+ CONTACT
67
+ ══════════════════════════════════════════════════════════════════════════
68
+
69
+ For licensing questions, security issues, or commercial support:
70
+ jeremiah@getbizsuite.com
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: mnemopay
3
+ Version: 1.0.0
4
+ Summary: Memory + Wallet for AI Agents. Give any agent persistent memory and micropayment capabilities.
5
+ Author-email: Jeremiah Omiagbo <jeremiah@getbizsuite.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://getbizsuite.com/mnemopay
8
+ Project-URL: Repository, https://github.com/mnemopay/mnemopay-python
9
+ Project-URL: Documentation, https://getbizsuite.com/mnemopay
10
+ Keywords: ai,agents,memory,payments,fico,behavioral-finance,anomaly-detection
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ License-File: NOTICE
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.0; extra == "dev"
29
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
30
+ Provides-Extra: stripe
31
+ Requires-Dist: stripe>=12.0.0; extra == "stripe"
32
+ Dynamic: license-file
33
+
34
+ # MnemoPay Python SDK
35
+
36
+ The governance layer for AI agents that handle money — Python edition. Mirrors the TypeScript [`@mnemopay/sdk`](https://www.npmjs.com/package/@mnemopay/sdk) shape so the same agent identity, score, charter, and audit chain work across both runtimes.
37
+
38
+ ```python
39
+ from mnemopay import MnemoPay
40
+
41
+ agent = MnemoPay("my-agent")
42
+ agent.remember("user prefers Python")
43
+ tx = agent.charge(10.00, "API call")
44
+ agent.settle(tx.id)
45
+ ```
46
+
47
+ ## Install
48
+
49
+ ```bash
50
+ pip install mnemopay # stdlib-only core
51
+ pip install "mnemopay[stripe]" # + StripeRail (peer-loaded `stripe>=12.0`)
52
+ ```
53
+
54
+ > **What MnemoPay is NOT:** not a bank, not a money transmitter, not a Stripe replacement, not an agent framework. It sits **above** the rail and **below** the runtime — declares the rules, enforces the budget, produces the evidence.
55
+
56
+ ## Features
57
+
58
+ - **Payment rails** (v1.0.0b4 — parity with TS v1.6.x): `MockRail` + `StripeRail` with manual-capture two-phase commit, threading-safe capture race-protection, idempotency-key forwarding
59
+ - **Cognitive Memory**: Ebbinghaus decay, Hebbian reinforcement, auto-scoring, Layer 2 semantic recall + RL feedback
60
+ - **Micropayments**: escrow-based charges with volume-tiered fees (1.9% / 1.5% / 1.0%)
61
+ - **Agent FICO**: agent credit scoring (300-850 range; not consumer FICO, not FCRA-regulated)
62
+ - **Behavioral Finance**: prospect theory, cooling-off periods, regret prediction
63
+ - **Merkle Integrity**: SHA-256 tamper detection for agent memory
64
+ - **Anomaly Detection**: EWMA streaming detector, behavioral fingerprinting, canary honeypots
65
+ - **Commerce**: autonomous shopping engine with mandates + escrow
66
+ - **Circuit Breaker**: AIMD rate limiting, anti-gaming, PSI drift detection
67
+ - **Stdlib core**: zero required dependencies — peer-deps only when you opt in (e.g. `stripe`)
68
+ - **Python 3.9+**: full type hints, dataclasses, sync API (matches the rest of the SDK)
69
+
70
+ ## Modules
71
+
72
+ | Module | Class | Description |
73
+ |--------|-------|-------------|
74
+ | `mnemopay.core` | `MnemoPay` | Memory + payments + reputation |
75
+ | `mnemopay.rails` | `PaymentRail`, `MockRail`, `StripeRail` | Payment rail abstraction (v1.0.0b4) |
76
+ | `mnemopay.fico` | `AgentFICO` | Credit scoring (300-850) |
77
+ | `mnemopay.behavioral` | `BehavioralEngine` | Behavioral finance tools |
78
+ | `mnemopay.integrity` | `MerkleTree` | SHA-256 tamper detection |
79
+ | `mnemopay.anomaly` | `EWMADetector`, `BehaviorMonitor`, `CanarySystem` | Anomaly detection |
80
+ | `mnemopay.commerce` | `CommerceEngine`, `CommerceProvider`, `Mandate` | Autonomous shopping |
81
+ | `mnemopay.circuit_breaker` | `CircuitBreaker`, `AIMDRateLimiter`, `AntiGamingEngine`, `PSIDriftDetector` | Adaptive defense |
82
+
83
+ ## Payment rails (v1.0.0b4)
84
+
85
+ Mirrors the TypeScript `PaymentRail` interface. Same shape (`create_hold` / `capture_payment` / `reverse_payment`), same drop-in-swap semantics. Sync API to match the rest of the Python SDK — no asyncio.
86
+
87
+ ```python
88
+ from mnemopay.rails import StripeRail, MockRail, HoldOptions
89
+
90
+ # Default — no infra, in-memory ledger, used in tests + dev
91
+ rail = MockRail()
92
+
93
+ # Production — real Stripe PaymentIntents with manual-capture two-phase commit
94
+ rail = StripeRail(secret_key="sk_test_...")
95
+
96
+ # Two-phase commit (hold → capture)
97
+ hold = rail.create_hold(
98
+ amount=25.00,
99
+ reason="Monthly access",
100
+ agent_id="agent-1",
101
+ opts=HoldOptions(
102
+ customer_id="cus_real",
103
+ payment_method_id="pm_real",
104
+ off_session=True,
105
+ metadata={"idempotencyKey": "req_abc"},
106
+ ),
107
+ )
108
+ capture = rail.capture_payment(hold.external_id, 25.00)
109
+ # capture.status == "succeeded"
110
+ # capture.receipt_id == "ch_..." # Stripe charge id
111
+
112
+ # Or reverse (cancel the hold) instead of capturing
113
+ rail.reverse_payment(hold.external_id, 25.00)
114
+ ```
115
+
116
+ `StripeRail` includes onboarding helpers for off-session charges:
117
+
118
+ ```python
119
+ result = rail.create_customer("user@example.com", name="Jerry O")
120
+ # {"customer_id": "cus_..."}
121
+
122
+ result = rail.create_setup_intent(customer_id="cus_...")
123
+ # {"setup_intent_id": "seti_...", "client_secret": "..."}
124
+ ```
125
+
126
+ For tests, inject a mock client:
127
+
128
+ ```python
129
+ from unittest.mock import MagicMock
130
+ rail = StripeRail.from_client(MagicMock(), currency="usd")
131
+ ```
132
+
133
+ ## Compatibility with `@mnemopay/sdk` (TypeScript)
134
+
135
+ | Feature | TypeScript v1.6.0-alpha.1 | Python v1.0.0b4 |
136
+ |---|---|---|
137
+ | `MockRail` | yes | yes |
138
+ | `StripeRail` | yes | yes |
139
+ | `PaystackRail` | yes | not yet |
140
+ | `LightningRail` | yes | not yet |
141
+ | `StripeMPPRail` (alpha) | yes | not yet |
142
+ | `X402Rail` (alpha) | yes | not yet |
143
+ | `GoogleAP2Rail` (alpha) | yes | not yet |
144
+ | Charter / FiscalGate / Article 12 (governance) | yes | not yet |
145
+ | Agent Credit Score | yes | yes |
146
+ | Behavioral Finance | yes | yes |
147
+ | Merkle integrity | yes | yes |
148
+ | Anomaly detection (EWMA + canary) | yes | yes |
149
+ | Commerce engine | yes | yes |
150
+ | Circuit breaker | yes | yes |
151
+
152
+ The Python SDK ships behind the TypeScript SDK — port priorities track agent-developer demand. Open an issue if you need a specific rail or governance primitive in Python.
153
+
154
+ ## Tests
155
+
156
+ ```bash
157
+ pip install -e ".[dev,stripe]"
158
+ pytest # 422 tests across 9 modules
159
+ pytest tests/test_rails.py -v # 29 rail-specific tests
160
+ ```
161
+
162
+ ## License
163
+
164
+ **v1.0.0+ is Apache License 2.0** — see [LICENSE](LICENSE) and [NOTICE](NOTICE).
165
+
166
+ The pre-release betas (`1.0.0b1` through `1.0.0b4`) shipped under the MIT
167
+ License and remain available under those terms on PyPI in perpetuity. If
168
+ you depend on the MIT terms specifically, pin to `mnemopay==1.0.0b4`.
169
+
170
+ Why Apache 2.0 at the stable cut: alignment with the canonical TypeScript
171
+ SDK at [`@mnemopay/sdk`](https://www.npmjs.com/package/@mnemopay/sdk) plus
172
+ the patent grant + retaliation clause for enterprise embedders.
173
+
174
+ Copyright 2026 J&B Enterprise LLC.
@@ -0,0 +1,141 @@
1
+ # MnemoPay Python SDK
2
+
3
+ The governance layer for AI agents that handle money — Python edition. Mirrors the TypeScript [`@mnemopay/sdk`](https://www.npmjs.com/package/@mnemopay/sdk) shape so the same agent identity, score, charter, and audit chain work across both runtimes.
4
+
5
+ ```python
6
+ from mnemopay import MnemoPay
7
+
8
+ agent = MnemoPay("my-agent")
9
+ agent.remember("user prefers Python")
10
+ tx = agent.charge(10.00, "API call")
11
+ agent.settle(tx.id)
12
+ ```
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pip install mnemopay # stdlib-only core
18
+ pip install "mnemopay[stripe]" # + StripeRail (peer-loaded `stripe>=12.0`)
19
+ ```
20
+
21
+ > **What MnemoPay is NOT:** not a bank, not a money transmitter, not a Stripe replacement, not an agent framework. It sits **above** the rail and **below** the runtime — declares the rules, enforces the budget, produces the evidence.
22
+
23
+ ## Features
24
+
25
+ - **Payment rails** (v1.0.0b4 — parity with TS v1.6.x): `MockRail` + `StripeRail` with manual-capture two-phase commit, threading-safe capture race-protection, idempotency-key forwarding
26
+ - **Cognitive Memory**: Ebbinghaus decay, Hebbian reinforcement, auto-scoring, Layer 2 semantic recall + RL feedback
27
+ - **Micropayments**: escrow-based charges with volume-tiered fees (1.9% / 1.5% / 1.0%)
28
+ - **Agent FICO**: agent credit scoring (300-850 range; not consumer FICO, not FCRA-regulated)
29
+ - **Behavioral Finance**: prospect theory, cooling-off periods, regret prediction
30
+ - **Merkle Integrity**: SHA-256 tamper detection for agent memory
31
+ - **Anomaly Detection**: EWMA streaming detector, behavioral fingerprinting, canary honeypots
32
+ - **Commerce**: autonomous shopping engine with mandates + escrow
33
+ - **Circuit Breaker**: AIMD rate limiting, anti-gaming, PSI drift detection
34
+ - **Stdlib core**: zero required dependencies — peer-deps only when you opt in (e.g. `stripe`)
35
+ - **Python 3.9+**: full type hints, dataclasses, sync API (matches the rest of the SDK)
36
+
37
+ ## Modules
38
+
39
+ | Module | Class | Description |
40
+ |--------|-------|-------------|
41
+ | `mnemopay.core` | `MnemoPay` | Memory + payments + reputation |
42
+ | `mnemopay.rails` | `PaymentRail`, `MockRail`, `StripeRail` | Payment rail abstraction (v1.0.0b4) |
43
+ | `mnemopay.fico` | `AgentFICO` | Credit scoring (300-850) |
44
+ | `mnemopay.behavioral` | `BehavioralEngine` | Behavioral finance tools |
45
+ | `mnemopay.integrity` | `MerkleTree` | SHA-256 tamper detection |
46
+ | `mnemopay.anomaly` | `EWMADetector`, `BehaviorMonitor`, `CanarySystem` | Anomaly detection |
47
+ | `mnemopay.commerce` | `CommerceEngine`, `CommerceProvider`, `Mandate` | Autonomous shopping |
48
+ | `mnemopay.circuit_breaker` | `CircuitBreaker`, `AIMDRateLimiter`, `AntiGamingEngine`, `PSIDriftDetector` | Adaptive defense |
49
+
50
+ ## Payment rails (v1.0.0b4)
51
+
52
+ Mirrors the TypeScript `PaymentRail` interface. Same shape (`create_hold` / `capture_payment` / `reverse_payment`), same drop-in-swap semantics. Sync API to match the rest of the Python SDK — no asyncio.
53
+
54
+ ```python
55
+ from mnemopay.rails import StripeRail, MockRail, HoldOptions
56
+
57
+ # Default — no infra, in-memory ledger, used in tests + dev
58
+ rail = MockRail()
59
+
60
+ # Production — real Stripe PaymentIntents with manual-capture two-phase commit
61
+ rail = StripeRail(secret_key="sk_test_...")
62
+
63
+ # Two-phase commit (hold → capture)
64
+ hold = rail.create_hold(
65
+ amount=25.00,
66
+ reason="Monthly access",
67
+ agent_id="agent-1",
68
+ opts=HoldOptions(
69
+ customer_id="cus_real",
70
+ payment_method_id="pm_real",
71
+ off_session=True,
72
+ metadata={"idempotencyKey": "req_abc"},
73
+ ),
74
+ )
75
+ capture = rail.capture_payment(hold.external_id, 25.00)
76
+ # capture.status == "succeeded"
77
+ # capture.receipt_id == "ch_..." # Stripe charge id
78
+
79
+ # Or reverse (cancel the hold) instead of capturing
80
+ rail.reverse_payment(hold.external_id, 25.00)
81
+ ```
82
+
83
+ `StripeRail` includes onboarding helpers for off-session charges:
84
+
85
+ ```python
86
+ result = rail.create_customer("user@example.com", name="Jerry O")
87
+ # {"customer_id": "cus_..."}
88
+
89
+ result = rail.create_setup_intent(customer_id="cus_...")
90
+ # {"setup_intent_id": "seti_...", "client_secret": "..."}
91
+ ```
92
+
93
+ For tests, inject a mock client:
94
+
95
+ ```python
96
+ from unittest.mock import MagicMock
97
+ rail = StripeRail.from_client(MagicMock(), currency="usd")
98
+ ```
99
+
100
+ ## Compatibility with `@mnemopay/sdk` (TypeScript)
101
+
102
+ | Feature | TypeScript v1.6.0-alpha.1 | Python v1.0.0b4 |
103
+ |---|---|---|
104
+ | `MockRail` | yes | yes |
105
+ | `StripeRail` | yes | yes |
106
+ | `PaystackRail` | yes | not yet |
107
+ | `LightningRail` | yes | not yet |
108
+ | `StripeMPPRail` (alpha) | yes | not yet |
109
+ | `X402Rail` (alpha) | yes | not yet |
110
+ | `GoogleAP2Rail` (alpha) | yes | not yet |
111
+ | Charter / FiscalGate / Article 12 (governance) | yes | not yet |
112
+ | Agent Credit Score | yes | yes |
113
+ | Behavioral Finance | yes | yes |
114
+ | Merkle integrity | yes | yes |
115
+ | Anomaly detection (EWMA + canary) | yes | yes |
116
+ | Commerce engine | yes | yes |
117
+ | Circuit breaker | yes | yes |
118
+
119
+ The Python SDK ships behind the TypeScript SDK — port priorities track agent-developer demand. Open an issue if you need a specific rail or governance primitive in Python.
120
+
121
+ ## Tests
122
+
123
+ ```bash
124
+ pip install -e ".[dev,stripe]"
125
+ pytest # 422 tests across 9 modules
126
+ pytest tests/test_rails.py -v # 29 rail-specific tests
127
+ ```
128
+
129
+ ## License
130
+
131
+ **v1.0.0+ is Apache License 2.0** — see [LICENSE](LICENSE) and [NOTICE](NOTICE).
132
+
133
+ The pre-release betas (`1.0.0b1` through `1.0.0b4`) shipped under the MIT
134
+ License and remain available under those terms on PyPI in perpetuity. If
135
+ you depend on the MIT terms specifically, pin to `mnemopay==1.0.0b4`.
136
+
137
+ Why Apache 2.0 at the stable cut: alignment with the canonical TypeScript
138
+ SDK at [`@mnemopay/sdk`](https://www.npmjs.com/package/@mnemopay/sdk) plus
139
+ the patent grant + retaliation clause for enterprise embedders.
140
+
141
+ Copyright 2026 J&B Enterprise LLC.