pdm-memory 0.1.2__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. pdm_memory-0.1.4/LICENSE +110 -0
  2. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/PKG-INFO +127 -54
  3. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/README.md +13 -3
  4. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/__init__.py +5 -1
  5. pdm_memory-0.1.4/pdm_memory/auth/__init__.py +8 -0
  6. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/auth/jwt_handler.py +4 -0
  7. pdm_memory-0.1.4/pdm_memory/bench.py +9 -0
  8. pdm_memory-0.1.4/pdm_memory/core/__init__.py +5 -0
  9. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/core/math.py +86 -40
  10. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/core/retrieval.py +17 -42
  11. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/core/signature.py +6 -2
  12. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/ingest/__init__.py +4 -0
  13. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/ingest/auto_signature.py +4 -0
  14. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/ingest/batch.py +4 -0
  15. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/ingest/ingester.py +4 -0
  16. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/integrations/__init__.py +4 -0
  17. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/integrations/anthropic_adapter.py +4 -0
  18. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/integrations/context_manager.py +4 -0
  19. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/integrations/gemini_adapter.py +4 -0
  20. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/integrations/groq_adapter.py +4 -0
  21. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/integrations/ollama_adapter.py +4 -0
  22. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/integrations/openai_adapter.py +4 -0
  23. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/memory.py +57 -44
  24. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/storage/__init__.py +4 -0
  25. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/storage/base.py +19 -5
  26. pdm_memory-0.1.4/pdm_memory/storage/cloud_driver.py +435 -0
  27. pdm_memory-0.1.4/pdm_memory/storage/errors.py +26 -0
  28. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/storage/sqlite_driver.py +96 -28
  29. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/sync.py +38 -7
  30. pdm_memory-0.1.4/pdm_memory/tools/__init__.py +5 -0
  31. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/tools/bench.py +4 -0
  32. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory/tools/cli.py +4 -0
  33. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory.egg-info/PKG-INFO +127 -54
  34. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory.egg-info/SOURCES.txt +2 -0
  35. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pyproject.toml +6 -3
  36. pdm_memory-0.1.4/tests/test_cloud_driver.py +164 -0
  37. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/tests/test_math.py +43 -11
  38. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/tests/test_memory.py +13 -0
  39. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/tests/test_sqlite_driver.py +33 -1
  40. pdm_memory-0.1.2/LICENSE +0 -50
  41. pdm_memory-0.1.2/pdm_memory/auth/__init__.py +0 -4
  42. pdm_memory-0.1.2/pdm_memory/bench.py +0 -5
  43. pdm_memory-0.1.2/pdm_memory/core/__init__.py +0 -1
  44. pdm_memory-0.1.2/pdm_memory/storage/cloud_driver.py +0 -271
  45. pdm_memory-0.1.2/pdm_memory/tools/__init__.py +0 -1
  46. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory.egg-info/dependency_links.txt +0 -0
  47. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory.egg-info/entry_points.txt +0 -0
  48. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory.egg-info/requires.txt +0 -0
  49. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/pdm_memory.egg-info/top_level.txt +0 -0
  50. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/setup.cfg +0 -0
  51. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/tests/test_bench.py +0 -0
  52. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/tests/test_cli.py +0 -0
  53. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/tests/test_gemini_adapter.py +0 -0
  54. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/tests/test_groq_adapter.py +0 -0
  55. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/tests/test_jwt_auth.py +0 -0
  56. {pdm_memory-0.1.2 → pdm_memory-0.1.4}/tests/test_ollama_adapter.py +0 -0
@@ -0,0 +1,110 @@
1
+ Elastic License 2.0 (ELv2)
2
+ =========================
3
+
4
+ Copyright (c) 2026 Westfield Innovations LLC
5
+
6
+ Core software modification and redistribution of altered versions are
7
+ prohibited without a commercial license from Westfield Innovations LLC.
8
+ Extensions via defined plugin interfaces (e.g., BaseStorage) are permitted.
9
+
10
+ Patent Pending — U.S. App. No. 19/739,419 | 63/953,563 | 63/953,842
11
+
12
+ The software in this repository is licensed under the Elastic License 2.0
13
+ (the text of which follows), subject to the additional Westfield Innovations
14
+ LLC restrictions stated above. Free use is permitted "as-shipped". Unauthorized
15
+ modification, forking, or redistribution of altered core logic is prohibited
16
+ without a separate commercial license from Westfield Innovations LLC.
17
+
18
+ --------------------------------------------------------------------------
19
+ Elastic License 2.0
20
+ --------------------------------------------------------------------------
21
+
22
+ ## Acceptance
23
+
24
+ By using the software, you agree to all of the terms and conditions below.
25
+
26
+ ## Copyright License
27
+
28
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
29
+ non-sublicensable, non-transferable license to use, copy, distribute, make
30
+ available, and prepare derivative works of the software, in each case subject
31
+ to the limitations and conditions below.
32
+
33
+ ## Limitations
34
+
35
+ You may not provide the software to third parties as a hosted or managed
36
+ service, where the service provides users with access to any substantial set
37
+ of the features or functionality of the software.
38
+
39
+ You may not move, change, disable, or circumvent the license key functionality
40
+ in the software, and you may not remove or obscure any functionality in the
41
+ software that is protected by the license key.
42
+
43
+ You may not alter, remove, or obscure any licensing, copyright, or other
44
+ notices of the licensor in the software. Any use of the licensor's trademarks
45
+ is subject to applicable law.
46
+
47
+ ## Patents
48
+
49
+ The licensor grants you a license, under any patent claims the licensor can
50
+ license, or becomes able to license, to make, have made, use, sell, offer for
51
+ sale, import and have imported the software, in each case subject to the
52
+ limitations and conditions in this license. This license does not cover any
53
+ patent claims that you cause to be infringed by modifications or additions to
54
+ the software. If you or your company make any written claim that the software
55
+ infringes or contributes to infringement of any patent, your patent license
56
+ for the software granted under these terms ends immediately. If your company
57
+ makes such a claim, your patent license ends immediately for work on behalf of
58
+ your company.
59
+
60
+ ## Notices
61
+
62
+ You must ensure that anyone who gets a copy of any part of the software from
63
+ you also gets a copy of these terms.
64
+
65
+ If you modify the software, you must include in any modified copies of the
66
+ software prominent notices stating that you have modified the software.
67
+
68
+ ## No Other Rights
69
+
70
+ These terms do not imply any licenses other than those expressly granted in
71
+ these terms.
72
+
73
+ ## Termination
74
+
75
+ If you use the software in violation of these terms, such use is not licensed,
76
+ and your licenses will automatically terminate. If the licensor provides you
77
+ with a notice of your violation, and you cease all violation of this license
78
+ no later than 30 days after you receive that notice, your licenses will be
79
+ reinstated retroactively. However, if you violate these terms after such
80
+ reinstatement, any additional violation of these terms will cause your
81
+ licenses to terminate automatically and permanently.
82
+
83
+ ## No Liability
84
+
85
+ As far as the law allows, the software comes as is, without any warranty or
86
+ condition, and the licensor will not be liable to you for any damages arising
87
+ out of these terms or the use or nature of the software, under any kind of
88
+ legal claim.
89
+
90
+ ## Definitions
91
+
92
+ The **licensor** is the entity offering these terms, and the **software** is
93
+ the software the licensor makes available under these terms, including any
94
+ portion of it.
95
+
96
+ **you** refers to the individual or entity agreeing to these terms.
97
+
98
+ **your company** is any legal entity, sole proprietorship, or other kind of
99
+ organization that you work for, plus all organizations that have control over,
100
+ are under the control of, or are under common control with that organization.
101
+ **control** means ownership of substantially all the assets of an entity, or
102
+ the power to direct its management and policies by vote, contract, or
103
+ otherwise. Control can be direct or indirect.
104
+
105
+ **your licenses** are all the licenses granted to you for the software under
106
+ these terms.
107
+
108
+ **use** means anything you do with the software requiring one of your licenses.
109
+
110
+ **trademark** means trademarks, service marks, and similar rights.
@@ -1,65 +1,128 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdm-memory
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Pressure-Driven Memory (PDM) — persistent, resonance-based memory for AI apps.
5
5
  Author: Westfield Innovations LLC
6
- License: MIT License with Patent Scope Clause
6
+ License: Elastic License 2.0 (ELv2)
7
+ =========================
7
8
 
8
9
  Copyright (c) 2026 Westfield Innovations LLC
9
10
 
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
28
- ─────────────────────────────────────────────
29
- PATENT SCOPE CLAUSE (Additional Terms)
30
- ─────────────────────────────────────────────
31
-
32
- The above MIT license grant covers the software source code in this repository.
33
- It does not grant any license to patents held or applied for by Westfield
34
- Innovations LLC, including but not limited to patents covering the following
35
- methods and systems embodied in the Pressure-Driven Memory (PDM) system:
36
-
37
- 1. Pressure-based memory retrieval and ranking (threshold-driven recall).
38
- 2. Resonance retrieval via threshold-adjustment search (TAS).
39
- 3. Temporal deformation geometry for deadline-aware memory pressure.
40
- 4. Validation coefficient computation for memory signal quality.
41
- 5. Incremental decay without a scheduler (time-delta-based decay on read).
42
-
43
- The license granted by this file permits you to:
44
- Use this SDK (pdm-memory) in your applications.
45
- Distribute applications that incorporate this SDK.
46
- ✓ Modify this SDK for your own use or contribution back to this repository.
47
-
48
- This license does NOT permit you to:
49
- Reimplement the patented PDM algorithms independently (outside this SDK).
50
- ✗ Use the patent claims of PDM to build a competing product.
51
- Sub-license the patent rights granted herein to third parties.
52
-
53
- Use of the SDK constitutes acceptance of these additional terms.
54
- For commercial licensing inquiries beyond the scope described above,
55
- contact: legal@westfieldinnovations.com
56
-
57
- Project-URL: Homepage, https://github.com/westfield-innovations/pdm-memory
11
+ Core software modification and redistribution of altered versions are
12
+ prohibited without a commercial license from Westfield Innovations LLC.
13
+ Extensions via defined plugin interfaces (e.g., BaseStorage) are permitted.
14
+
15
+ Patent Pending U.S. App. No. 19/739,419 | 63/953,563 | 63/953,842
16
+
17
+ The software in this repository is licensed under the Elastic License 2.0
18
+ (the text of which follows), subject to the additional Westfield Innovations
19
+ LLC restrictions stated above. Free use is permitted "as-shipped". Unauthorized
20
+ modification, forking, or redistribution of altered core logic is prohibited
21
+ without a separate commercial license from Westfield Innovations LLC.
22
+
23
+ --------------------------------------------------------------------------
24
+ Elastic License 2.0
25
+ --------------------------------------------------------------------------
26
+
27
+ ## Acceptance
28
+
29
+ By using the software, you agree to all of the terms and conditions below.
30
+
31
+ ## Copyright License
32
+
33
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
34
+ non-sublicensable, non-transferable license to use, copy, distribute, make
35
+ available, and prepare derivative works of the software, in each case subject
36
+ to the limitations and conditions below.
37
+
38
+ ## Limitations
39
+
40
+ You may not provide the software to third parties as a hosted or managed
41
+ service, where the service provides users with access to any substantial set
42
+ of the features or functionality of the software.
43
+
44
+ You may not move, change, disable, or circumvent the license key functionality
45
+ in the software, and you may not remove or obscure any functionality in the
46
+ software that is protected by the license key.
47
+
48
+ You may not alter, remove, or obscure any licensing, copyright, or other
49
+ notices of the licensor in the software. Any use of the licensor's trademarks
50
+ is subject to applicable law.
51
+
52
+ ## Patents
53
+
54
+ The licensor grants you a license, under any patent claims the licensor can
55
+ license, or becomes able to license, to make, have made, use, sell, offer for
56
+ sale, import and have imported the software, in each case subject to the
57
+ limitations and conditions in this license. This license does not cover any
58
+ patent claims that you cause to be infringed by modifications or additions to
59
+ the software. If you or your company make any written claim that the software
60
+ infringes or contributes to infringement of any patent, your patent license
61
+ for the software granted under these terms ends immediately. If your company
62
+ makes such a claim, your patent license ends immediately for work on behalf of
63
+ your company.
64
+
65
+ ## Notices
66
+
67
+ You must ensure that anyone who gets a copy of any part of the software from
68
+ you also gets a copy of these terms.
69
+
70
+ If you modify the software, you must include in any modified copies of the
71
+ software prominent notices stating that you have modified the software.
72
+
73
+ ## No Other Rights
74
+
75
+ These terms do not imply any licenses other than those expressly granted in
76
+ these terms.
77
+
78
+ ## Termination
79
+
80
+ If you use the software in violation of these terms, such use is not licensed,
81
+ and your licenses will automatically terminate. If the licensor provides you
82
+ with a notice of your violation, and you cease all violation of this license
83
+ no later than 30 days after you receive that notice, your licenses will be
84
+ reinstated retroactively. However, if you violate these terms after such
85
+ reinstatement, any additional violation of these terms will cause your
86
+ licenses to terminate automatically and permanently.
87
+
88
+ ## No Liability
89
+
90
+ As far as the law allows, the software comes as is, without any warranty or
91
+ condition, and the licensor will not be liable to you for any damages arising
92
+ out of these terms or the use or nature of the software, under any kind of
93
+ legal claim.
94
+
95
+ ## Definitions
96
+
97
+ The **licensor** is the entity offering these terms, and the **software** is
98
+ the software the licensor makes available under these terms, including any
99
+ portion of it.
100
+
101
+ **you** refers to the individual or entity agreeing to these terms.
102
+
103
+ **your company** is any legal entity, sole proprietorship, or other kind of
104
+ organization that you work for, plus all organizations that have control over,
105
+ are under the control of, or are under common control with that organization.
106
+ **control** means ownership of substantially all the assets of an entity, or
107
+ the power to direct its management and policies by vote, contract, or
108
+ otherwise. Control can be direct or indirect.
109
+
110
+ **your licenses** are all the licenses granted to you for the software under
111
+ these terms.
112
+
113
+ **use** means anything you do with the software requiring one of your licenses.
114
+
115
+ **trademark** means trademarks, service marks, and similar rights.
116
+
117
+ Project-URL: Homepage, https://azus.ai
118
+ Project-URL: Documentation, https://azus.ai
58
119
  Project-URL: Bug Tracker, https://github.com/westfield-innovations/pdm-memory/issues
120
+ Project-URL: Source, https://github.com/westfield-innovations/pdm-memory
121
+ Project-URL: Repository, https://github.com/westfield-innovations/pdm-memory
59
122
  Keywords: ai,memory,llm,rag,pressure-driven,persistent-memory
60
123
  Classifier: Development Status :: 4 - Beta
61
124
  Classifier: Intended Audience :: Developers
62
- Classifier: License :: OSI Approved :: MIT License
125
+ Classifier: License :: Other/Proprietary License
63
126
  Classifier: Programming Language :: Python :: 3
64
127
  Classifier: Programming Language :: Python :: 3.10
65
128
  Classifier: Programming Language :: Python :: 3.11
@@ -106,7 +169,7 @@ Dynamic: license-file
106
169
  [![PyPI](https://img.shields.io/pypi/v/pdm-memory)](https://pypi.org/project/pdm-memory/)
107
170
  [![Python](https://img.shields.io/pypi/pyversions/pdm-memory)](https://pypi.org/project/pdm-memory/)
108
171
  [![CI](https://github.com/westfield-innovations/pdm-memory/actions/workflows/ci.yml/badge.svg)](https://github.com/westfield-innovations/pdm-memory/actions)
109
- [![License: MIT](https://img.shields.io/badge/License-MIT%2BPatent-blue)](LICENSE)
172
+ [![License: Proprietary](https://img.shields.io/badge/License-Proprietary%20ELv2-blue)](LICENSE)
110
173
 
111
174
  Your LLM forgets everything between conversations. The standard fix — stuff a vector database into the context window — is expensive, slow, and retrieves **what matches words, not what matters**.
112
175
 
@@ -480,6 +543,16 @@ mem._engine = RetrievalEngine()
480
543
 
481
544
  ## 📄 License
482
545
 
483
- [MIT + Patent Scope Clause](LICENSE) — use the SDK freely; the PDM algorithm patents stay with Westfield Innovations LLC.
546
+ Free to use **as-shipped** under a custom [Elastic License 2.0 (ELv2)](LICENSE)
547
+ base from **Westfield Innovations LLC**.
548
+
549
+ - Use the SDK as distributed: yes.
550
+ - Modify / fork / redistribute altered **core** logic: **no**, without a
551
+ commercial license from Westfield Innovations LLC.
552
+ - Extensions via defined plugin interfaces (e.g. `BaseStorage`): **permitted**.
553
+
554
+ **Patent Pending** — U.S. App. No. **19/739,419** · **63/953,563** · **63/953,842**.
555
+
556
+ If this software makes you money, send Carl a birthday card. He collects them.
484
557
 
485
- Built by **Westfield Innovations LLC** · [westfieldinnovations.com](https://westfieldinnovations.com)
558
+ Built by **Westfield Innovations LLC** · [azus.ai](https://azus.ai) · [getdeepsignals.com](https://getdeepsignals.com)
@@ -3,7 +3,7 @@
3
3
  [![PyPI](https://img.shields.io/pypi/v/pdm-memory)](https://pypi.org/project/pdm-memory/)
4
4
  [![Python](https://img.shields.io/pypi/pyversions/pdm-memory)](https://pypi.org/project/pdm-memory/)
5
5
  [![CI](https://github.com/westfield-innovations/pdm-memory/actions/workflows/ci.yml/badge.svg)](https://github.com/westfield-innovations/pdm-memory/actions)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT%2BPatent-blue)](LICENSE)
6
+ [![License: Proprietary](https://img.shields.io/badge/License-Proprietary%20ELv2-blue)](LICENSE)
7
7
 
8
8
  Your LLM forgets everything between conversations. The standard fix — stuff a vector database into the context window — is expensive, slow, and retrieves **what matches words, not what matters**.
9
9
 
@@ -377,6 +377,16 @@ mem._engine = RetrievalEngine()
377
377
 
378
378
  ## 📄 License
379
379
 
380
- [MIT + Patent Scope Clause](LICENSE) — use the SDK freely; the PDM algorithm patents stay with Westfield Innovations LLC.
380
+ Free to use **as-shipped** under a custom [Elastic License 2.0 (ELv2)](LICENSE)
381
+ base from **Westfield Innovations LLC**.
381
382
 
382
- Built by **Westfield Innovations LLC** · [westfieldinnovations.com](https://westfieldinnovations.com)
383
+ - Use the SDK as distributed: yes.
384
+ - Modify / fork / redistribute altered **core** logic: **no**, without a
385
+ commercial license from Westfield Innovations LLC.
386
+ - Extensions via defined plugin interfaces (e.g. `BaseStorage`): **permitted**.
387
+
388
+ **Patent Pending** — U.S. App. No. **19/739,419** · **63/953,563** · **63/953,842**.
389
+
390
+ If this software makes you money, send Carl a birthday card. He collects them.
391
+
392
+ Built by **Westfield Innovations LLC** · [azus.ai](https://azus.ai) · [getdeepsignals.com](https://getdeepsignals.com)
@@ -1,3 +1,7 @@
1
+ # © 2026 Westfield Innovations LLC. Patent Pending.
2
+ # U.S. App. No. 19/739,419 | 63/953,563 | 63/953,842
3
+ # MODIFICATION PROHIBITED. USE AS SHIPPED.
4
+
1
5
  """
2
6
  pdm_memory — Pressure-Driven Memory SDK
3
7
  ========================================
@@ -18,5 +22,5 @@ See README.md for full documentation.
18
22
  from pdm_memory.memory import Memory
19
23
  from pdm_memory.core.signature import MemoryHit, DrawerInfo
20
24
 
21
- __version__ = "0.1.0"
25
+ __version__ = "0.1.3"
22
26
  __all__ = ["Memory", "MemoryHit", "DrawerInfo", "__version__"]
@@ -0,0 +1,8 @@
1
+ # © 2026 Westfield Innovations LLC. Patent Pending.
2
+ # U.S. App. No. 19/739,419 | 63/953,563 | 63/953,842
3
+ # MODIFICATION PROHIBITED. USE AS SHIPPED.
4
+
5
+ """pdm_memory.auth package."""
6
+ from pdm_memory.auth.jwt_handler import JWTAuth
7
+
8
+ __all__ = ["JWTAuth"]
@@ -1,3 +1,7 @@
1
+ # © 2026 Westfield Innovations LLC. Patent Pending.
2
+ # U.S. App. No. 19/739,419 | 63/953,563 | 63/953,842
3
+ # MODIFICATION PROHIBITED. USE AS SHIPPED.
4
+
1
5
  """
2
6
  JWT Auth Handler — Task 2.2
3
7
 
@@ -0,0 +1,9 @@
1
+ # © 2026 Westfield Innovations LLC. Patent Pending.
2
+ # U.S. App. No. 19/739,419 | 63/953,563 | 63/953,842
3
+ # MODIFICATION PROHIBITED. USE AS SHIPPED.
4
+
5
+ """Entry point for: python -m pdm_memory.bench"""
6
+ from pdm_memory.tools.bench import main
7
+
8
+ if __name__ == "__main__":
9
+ main()
@@ -0,0 +1,5 @@
1
+ # © 2026 Westfield Innovations LLC. Patent Pending.
2
+ # U.S. App. No. 19/739,419 | 63/953,563 | 63/953,842
3
+ # MODIFICATION PROHIBITED. USE AS SHIPPED.
4
+
5
+ """pdm_memory.core package."""
@@ -1,20 +1,29 @@
1
+ # © 2026 Westfield Innovations LLC. Patent Pending.
2
+ # U.S. App. No. 19/739,419 | 63/953,563 | 63/953,842
3
+ # MODIFICATION PROHIBITED. USE AS SHIPPED.
4
+
1
5
  """
2
6
  PDM Core Math — Pure Python, zero external dependencies.
3
7
 
4
8
  All formulas are ported faithfully from companion_api/pdm/kernel.py
5
9
  and companion_api/pdm/models.py. No Django, no ORM, no Celery.
6
10
 
7
- Formula reference:
11
+ Formula reference (ONE canonical decay law):
8
12
  effective_spike = min(100, P_magnitude × (t_persistence/30) × phase_privilege)
9
13
  decay_factor = 1 - exp(-λ × t) where λ = ln2 / half_life
10
14
  V = (correct + 1) / (total + 2) [Laplace smoothing]
11
15
  P_effective = P × V × (1 - decay_factor) × intent_weight × quality × comparator
12
- incremental_decay: new_p = p * (decay_rate ** days_elapsed) (no-scheduler version)
16
+
17
+ Grace: if days_since_created ≤ t_persistence → decay_factor = 0.
18
+ Surviving fraction = (1 - decay_factor) = exp(-λ × t).
19
+
20
+ Legacy power-law (p × decay_rate^days) is REMOVED — it double-penalized recall.
13
21
  """
14
22
 
15
23
  from __future__ import annotations
16
24
 
17
25
  import math
26
+ import warnings
18
27
  from typing import Dict, List, Optional
19
28
 
20
29
 
@@ -38,10 +47,10 @@ DEFAULT_HALF_LIFE: float = 30.0
38
47
  P_MAX: float = 100.0
39
48
  P_FLOOR: float = 0.0
40
49
 
41
- # Decay trigger — signatures below this are eligible for deletion
50
+ # Decay trigger — signatures below this live P_eff are eligible for deletion
42
51
  DECAY_DELETE_THRESHOLD: float = 30.0
43
52
 
44
- # Default decay multiplier (10% pressure loss per cycle)
53
+ # Kept for SignatureRecord/schema backward-compat only NOT used by pressure decay.
45
54
  DEFAULT_DECAY_RATE: float = 0.9
46
55
 
47
56
 
@@ -71,28 +80,38 @@ def calculate_effective_spike(
71
80
  return min(P_MAX, max(P_FLOOR, raw))
72
81
 
73
82
 
83
+ def resolve_half_life(domain: Optional[str]) -> float:
84
+ """Map knowledge domain → half-life days (canonical decay clock)."""
85
+ if not domain:
86
+ return DEFAULT_HALF_LIFE
87
+ return DOMAIN_HALF_LIVES.get(domain, DEFAULT_HALF_LIFE)
88
+
89
+
74
90
  def calculate_decay_factor(
75
91
  days_since_retrieved: float,
76
92
  half_life: float = DEFAULT_HALF_LIFE,
93
+ *,
94
+ days_since_created: Optional[float] = None,
95
+ t_persistence: float = 0.0,
77
96
  ) -> float:
78
97
  """
79
- Exponential decay factor based on time since last retrieval.
98
+ Canonical exponential decay factor based on time since last retrieval.
80
99
 
81
100
  decay_factor = 1 - exp(-λ × t) where λ = ln2 / half_life
82
101
 
102
+ Grace window: if ``days_since_created`` is provided and
103
+ ``days_since_created <= t_persistence``, returns 0.0 (no decay yet).
104
+
83
105
  A decay_factor close to 0 means the memory is fresh (little decay).
84
106
  A decay_factor close to 1 means the memory is very stale.
85
-
86
- Args:
87
- days_since_retrieved: Days since this memory was last accessed.
88
- half_life: Domain-specific half-life in days.
89
-
90
- Returns:
91
- decay_factor in [0, 1].
92
107
  """
108
+ if days_since_created is not None and days_since_created <= max(0.0, t_persistence):
109
+ return 0.0
110
+
111
+ days = max(0.0, float(days_since_retrieved))
93
112
  half_life = max(0.1, half_life)
94
113
  lam = math.log(2) / half_life
95
- return 1.0 - math.exp(-lam * days_since_retrieved)
114
+ return 1.0 - math.exp(-lam * days)
96
115
 
97
116
 
98
117
  def calculate_v(correct: int, total: int) -> float:
@@ -169,50 +188,77 @@ def calculate_p_effective(
169
188
 
170
189
 
171
190
  # ---------------------------------------------------------------------------
172
- # Task 1.4: Incremental decay (no Celery computed on every recall())
191
+ # Maintenance projection of stored pressure (same half-life law as P_effective)
173
192
  # ---------------------------------------------------------------------------
174
193
 
175
194
 
176
- def calculate_incremental_decay(
195
+ def calculate_half_life_pressure(
177
196
  p_magnitude: float,
178
- days_elapsed: float,
197
+ days_since_retrieved: float,
198
+ half_life: float,
179
199
  t_persistence: float,
180
200
  phase_privilege: float = 1.0,
181
- decay_per_day: float = DEFAULT_DECAY_RATE,
201
+ *,
202
+ days_since_created: Optional[float] = None,
182
203
  ) -> tuple[float, float]:
183
204
  """
184
- Compute decayed p_magnitude and effective_spike without a scheduler.
185
-
186
- Decay only fires after t_persistence days. If days_elapsed ≤ t_persistence,
187
- the memory is within its guaranteed persistence window — no decay applied.
205
+ Project stored pressure after canonical half-life decay.
188
206
 
189
- Formula:
190
- If days_elapsed > t_persistence:
191
- decayed_p = p_magnitude × decay_per_day^(days_elapsed - t_persistence)
192
- else:
193
- decayed_p = p_magnitude (still in persistence window)
207
+ Uses the SAME law as live scoring:
208
+ new_p = p_magnitude × (1 - decay_factor) = p_magnitude × exp(-λ × t)
194
209
 
195
- Args:
196
- p_magnitude: Current stored pressure.
197
- days_elapsed: Days since the memory was created (or last decayed).
198
- t_persistence: Guaranteed persistence window in days.
199
- phase_privilege: Phase multiplier for effective_spike.
200
- decay_per_day: Multiplier per day past persistence (default 0.9 = 10% loss/day).
210
+ Prefer deleting by live ``P_effective`` over rewriting ``p_magnitude``.
211
+ This helper exists for maintenance tooling / tests that need a projected P.
201
212
 
202
213
  Returns:
203
- Tuple (decayed_p_magnitude, new_effective_spike).
214
+ Tuple (projected_p_magnitude, new_effective_spike).
204
215
  """
205
- if days_elapsed <= t_persistence:
206
- new_p = p_magnitude
207
- else:
208
- days_past = days_elapsed - t_persistence
209
- new_p = p_magnitude * (decay_per_day ** days_past)
210
-
211
- new_p = max(0.0, min(P_MAX, new_p))
216
+ created_days = (
217
+ days_since_created
218
+ if days_since_created is not None
219
+ else days_since_retrieved
220
+ )
221
+ decay = calculate_decay_factor(
222
+ days_since_retrieved,
223
+ half_life,
224
+ days_since_created=created_days,
225
+ t_persistence=t_persistence,
226
+ )
227
+ new_p = max(P_FLOOR, min(P_MAX, p_magnitude * (1.0 - decay)))
212
228
  new_spike = calculate_effective_spike(new_p, t_persistence, phase_privilege)
213
229
  return round(new_p, 6), round(new_spike, 6)
214
230
 
215
231
 
232
+ def calculate_incremental_decay(
233
+ p_magnitude: float,
234
+ days_elapsed: float,
235
+ t_persistence: float,
236
+ phase_privilege: float = 1.0,
237
+ decay_per_day: float = DEFAULT_DECAY_RATE,
238
+ half_life: float = DEFAULT_HALF_LIFE,
239
+ ) -> tuple[float, float]:
240
+ """
241
+ DEPRECATED alias for :func:`calculate_half_life_pressure`.
242
+
243
+ The old power-law ``p × decay_per_day^days`` double-counted with live
244
+ half-life scoring and is no longer applied. ``decay_per_day`` is ignored.
245
+ """
246
+ warnings.warn(
247
+ "calculate_incremental_decay is deprecated; use calculate_half_life_pressure "
248
+ "(canonical domain half-life). decay_per_day is ignored.",
249
+ DeprecationWarning,
250
+ stacklevel=2,
251
+ )
252
+ return calculate_half_life_pressure(
253
+ p_magnitude=p_magnitude,
254
+ days_since_retrieved=max(0.0, days_elapsed - max(0.0, t_persistence)),
255
+ half_life=half_life,
256
+ t_persistence=t_persistence,
257
+ phase_privilege=phase_privilege,
258
+ days_since_created=days_elapsed,
259
+ )
260
+
261
+
216
262
  # ---------------------------------------------------------------------------
217
263
  # Task 1.3: Temporal geometry (PDM-T), ported from models.py
218
264
  # ---------------------------------------------------------------------------