muster-memory 0.1.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.
- muster_memory-0.1.0/.gitignore +55 -0
- muster_memory-0.1.0/LICENSE +202 -0
- muster_memory-0.1.0/NOTICE +6 -0
- muster_memory-0.1.0/PKG-INFO +203 -0
- muster_memory-0.1.0/README.md +389 -0
- muster_memory-0.1.0/docs/library/README.md +162 -0
- muster_memory-0.1.0/docs/library/api.md +89 -0
- muster_memory-0.1.0/docs/library/declared-records.md +74 -0
- muster_memory-0.1.0/docs/library/exact.md +60 -0
- muster_memory-0.1.0/docs/library/integrations.md +109 -0
- muster_memory-0.1.0/docs/library/performance.md +104 -0
- muster_memory-0.1.0/docs/library/verify.md +48 -0
- muster_memory-0.1.0/muster/__init__.py +27 -0
- muster_memory-0.1.0/muster/_version.py +1 -0
- muster_memory-0.1.0/muster/adapters.py +33 -0
- muster_memory-0.1.0/muster/bpe.py +130 -0
- muster_memory-0.1.0/muster/cache.py +68 -0
- muster_memory-0.1.0/muster/cli.py +248 -0
- muster_memory-0.1.0/muster/compat/__init__.py +1 -0
- muster_memory-0.1.0/muster/compat/bundles.py +145 -0
- muster_memory-0.1.0/muster/compat/ce_cache.py +47 -0
- muster_memory-0.1.0/muster/compat/env.py +39 -0
- muster_memory-0.1.0/muster/compat/intermediates.py +140 -0
- muster_memory-0.1.0/muster/compat/recover.py +75 -0
- muster_memory-0.1.0/muster/compat/verify.py +142 -0
- muster_memory-0.1.0/muster/cut.py +291 -0
- muster_memory-0.1.0/muster/derive.py +146 -0
- muster_memory-0.1.0/muster/errors.py +39 -0
- muster_memory-0.1.0/muster/index.py +102 -0
- muster_memory-0.1.0/muster/integrations/__init__.py +9 -0
- muster_memory-0.1.0/muster/integrations/_common.py +30 -0
- muster_memory-0.1.0/muster/integrations/langchain.py +26 -0
- muster_memory-0.1.0/muster/integrations/langgraph.py +19 -0
- muster_memory-0.1.0/muster/integrations/openai_agents.py +32 -0
- muster_memory-0.1.0/muster/io.py +33 -0
- muster_memory-0.1.0/muster/memory.py +254 -0
- muster_memory-0.1.0/muster/models.py +128 -0
- muster_memory-0.1.0/muster/plan.py +75 -0
- muster_memory-0.1.0/muster/presets/__init__.py +43 -0
- muster_memory-0.1.0/muster/presets/paper.json +1182 -0
- muster_memory-0.1.0/muster/record_serial.py +90 -0
- muster_memory-0.1.0/muster/records.py +120 -0
- muster_memory-0.1.0/muster/render.py +89 -0
- muster_memory-0.1.0/muster/search.py +328 -0
- muster_memory-0.1.0/muster/serve.py +158 -0
- muster_memory-0.1.0/muster/source_order.py +197 -0
- muster_memory-0.1.0/muster/stats.py +108 -0
- muster_memory-0.1.0/muster/store.py +186 -0
- muster_memory-0.1.0/pyproject.toml +55 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# credentials: never committed
|
|
2
|
+
.keys.sh
|
|
3
|
+
*.key
|
|
4
|
+
*.pem
|
|
5
|
+
.env
|
|
6
|
+
.env.*
|
|
7
|
+
*token*
|
|
8
|
+
*secret*
|
|
9
|
+
|
|
10
|
+
# benchmark data is fetched, never committed (root-level only: harness/beam/ holds the BEAM parquet builders)
|
|
11
|
+
/data/
|
|
12
|
+
/beam/
|
|
13
|
+
*.parquet
|
|
14
|
+
harness/buildtime_rtx/data/
|
|
15
|
+
|
|
16
|
+
# run outputs, caches, ledgers
|
|
17
|
+
results/
|
|
18
|
+
bundle_out/
|
|
19
|
+
cost_ledger/
|
|
20
|
+
ce_cache*/
|
|
21
|
+
extract_cache*/
|
|
22
|
+
wts_cache/
|
|
23
|
+
logs*/
|
|
24
|
+
*.log
|
|
25
|
+
*.jsonl.bak*
|
|
26
|
+
|
|
27
|
+
# environments and build artifacts
|
|
28
|
+
.venv/
|
|
29
|
+
__pycache__/
|
|
30
|
+
*.pyc
|
|
31
|
+
.DS_Store
|
|
32
|
+
|
|
33
|
+
# local notes
|
|
34
|
+
private/
|
|
35
|
+
|
|
36
|
+
# local tool settings
|
|
37
|
+
CLAUDE.md
|
|
38
|
+
.claude/
|
|
39
|
+
|
|
40
|
+
# local page reviews
|
|
41
|
+
docs/review/
|
|
42
|
+
|
|
43
|
+
# local page drafts
|
|
44
|
+
docs/index_*.html
|
|
45
|
+
|
|
46
|
+
# benchmark repositories fetched by scripts/fetch_mab_repo.sh and scripts/fetch_beam_repo.sh: never committed
|
|
47
|
+
harness/mab_repo/
|
|
48
|
+
harness/beam/BEAM/
|
|
49
|
+
|
|
50
|
+
# library build artifacts and stores the examples create
|
|
51
|
+
dist/
|
|
52
|
+
build/
|
|
53
|
+
*.egg-info/
|
|
54
|
+
*.muster
|
|
55
|
+
*.muster.scores
|
|
@@ -0,0 +1,202 @@
|
|
|
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 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 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 those 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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: muster-memory
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MUSTER: lossless long-term memory for agents, set by its own text, with no LLM calls to build or grow it
|
|
5
|
+
Project-URL: Homepage, https://saintmachines.github.io/MUSTER/
|
|
6
|
+
Project-URL: Repository, https://github.com/saintmachines/MUSTER
|
|
7
|
+
Project-URL: Documentation, https://github.com/saintmachines/MUSTER/blob/main/docs/library/README.md
|
|
8
|
+
Project-URL: Issues, https://github.com/saintmachines/MUSTER/issues
|
|
9
|
+
Author: SAINT Machines
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Requires-Dist: tiktoken>=0.7
|
|
17
|
+
Provides-Extra: agents
|
|
18
|
+
Requires-Dist: openai-agents<0.25,>=0.24; extra == 'agents'
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: build; extra == 'dev'
|
|
21
|
+
Requires-Dist: hatchling; extra == 'dev'
|
|
22
|
+
Requires-Dist: hypothesis; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
24
|
+
Provides-Extra: langchain
|
|
25
|
+
Requires-Dist: langchain-core<2,>=1.6; extra == 'langchain'
|
|
26
|
+
Provides-Extra: langgraph
|
|
27
|
+
Requires-Dist: langgraph<2,>=1.2; extra == 'langgraph'
|
|
28
|
+
Provides-Extra: mcp
|
|
29
|
+
Requires-Dist: mcp>=1.2; extra == 'mcp'
|
|
30
|
+
Provides-Extra: models
|
|
31
|
+
Requires-Dist: nltk>=3.9.1; extra == 'models'
|
|
32
|
+
Requires-Dist: numpy>=1.26; extra == 'models'
|
|
33
|
+
Requires-Dist: rank-bm25==0.2.2; extra == 'models'
|
|
34
|
+
Requires-Dist: sentence-transformers<6,>=5; extra == 'models'
|
|
35
|
+
Requires-Dist: torch>=2.3; extra == 'models'
|
|
36
|
+
Requires-Dist: transformers; extra == 'models'
|
|
37
|
+
Provides-Extra: parquet
|
|
38
|
+
Requires-Dist: pandas; extra == 'parquet'
|
|
39
|
+
Requires-Dist: pyarrow; extra == 'parquet'
|
|
40
|
+
Description-Content-Type: text/markdown
|
|
41
|
+
|
|
42
|
+
# MUSTER memory library
|
|
43
|
+
|
|
44
|
+
Long-term memory for agents that keeps every word. It reads its own text to decide how to cut, group and search it,
|
|
45
|
+
and it makes no LLM call to build or grow the memory. This package is the method of the MUSTER paper as a library:
|
|
46
|
+
the paper's runs are reproduced by it, question by question (see [Verification](#verification)).
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
Install `muster-memory` from PyPI. The basic install provides structure inspection.
|
|
51
|
+
The commands below add local retrieval models and the optional MCP server.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install "muster-memory[models]" # build, add and search (bge-m3 and bge-reranker-v2-m3, run locally)
|
|
55
|
+
pip install "muster-memory[models,mcp]" # also the MCP server
|
|
56
|
+
muster fetch # optional: tokenizer and sentence-splitter files for offline use
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`pip install muster-memory` alone gives `muster derive` and `muster.derive()`, which need only `tiktoken`. The
|
|
60
|
+
package imports as `muster`; `pip install muster` (without `-memory`) installs an unrelated 2017 project.
|
|
61
|
+
The paper's harness and the tests run from a clone of the repository.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
git clone https://github.com/saintmachines/MUSTER.git
|
|
65
|
+
cd MUSTER
|
|
66
|
+
pip install ".[models,mcp]"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Try it on a file
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
muster query chat.jsonl "Where does Caroline live now?" --explain # one JSON record per line, or a .txt file
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Use it in three lines
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import muster
|
|
79
|
+
|
|
80
|
+
mem = muster.build([
|
|
81
|
+
{"speaker": "Caroline", "time": "2023-05-08", "text": "I moved to Lisbon last month for the new job."},
|
|
82
|
+
{"speaker": "Melanie", "time": "2023-05-08", "text": "How do you like the city so far?"},
|
|
83
|
+
# ... thousands more
|
|
84
|
+
])
|
|
85
|
+
print(mem.context("Where does Caroline live now?").text) # what your LLM reads, verbatim and grouped
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`muster.build` derives the plan from the text: a numbered log (most lines start with `12. `), a record store (most of
|
|
89
|
+
the text sits in short blank-line records, like a chat) or prose (books, documents). `print(muster.explain(mem.plan))`
|
|
90
|
+
shows the decision and why. Nothing is tuned per dataset.
|
|
91
|
+
|
|
92
|
+
The numbered branch reads a serial written in the log's own style (`Step 12: ...`, `#12 ...`, `(12) ...`) the same way as
|
|
93
|
+
the paper's `12. ...`. It applies when 95% of the lines after the first carry a serial one above the previous line's and
|
|
94
|
+
the median line is at most 20 tokens, and the reader sees each line as written. The check was added after the paper and
|
|
95
|
+
its two thresholds were set on public benchmark logs; the paper's presets and `derive_collection` do not use it.
|
|
96
|
+
|
|
97
|
+
## A memory that grows: `Store`
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
store = muster.Store.open("agent.muster") # one SQLite file
|
|
101
|
+
store.add({"speaker": "user", "text": "My daughter's name is Ana.", "time": "2026-10-20T09:12"})
|
|
102
|
+
store.add(messages, request_id="turn-41") # a retried request is applied once
|
|
103
|
+
ctx = store.context("What is my daughter's name?")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`add` writes records in one transaction and calls no model, so it is safe on a hot path. The next search builds the
|
|
107
|
+
new version exactly as a fresh build of all records would be (tested), embedding only texts it has not seen before.
|
|
108
|
+
Cached unit vectors and reranker scores survive restarts; new queries still run retrieval models.
|
|
109
|
+
|
|
110
|
+
## Connect it
|
|
111
|
+
|
|
112
|
+
**MCP** (Claude Desktop, Claude Code, Cursor, any MCP client):
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
muster mcp --store agent.muster
|
|
116
|
+
```
|
|
117
|
+
```json
|
|
118
|
+
{"mcpServers": {"muster": {"command": "muster", "args": ["mcp", "--store", "/path/to/agent.muster"]}}}
|
|
119
|
+
```
|
|
120
|
+
Tools: `remember`, `remember_many`, `recall`, `search_memory`, `memory_info`.
|
|
121
|
+
|
|
122
|
+
**HTTP** (any app, service or robot):
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
muster http --store agent.muster --port 8765
|
|
126
|
+
curl -s localhost:8765/v1/add -d '{"records":[{"speaker":"robot","text":"Red mug on the kitchen table","time":"2026-10-20T10:02"}]}'
|
|
127
|
+
curl -s localhost:8765/v1/context -d '{"query":"Where did I last see the red mug?"}'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Python agents**: `Store.context(q).text` is a string; put it in the prompt. `ctx.messages(question)` builds a chat
|
|
131
|
+
message list; `ctx.blocks` gives the groups with the ids of the passages in each.
|
|
132
|
+
|
|
133
|
+
Examples: [examples/][examples] (agent loop, robot observation log, MCP client configuration, ROS 2 node).
|
|
134
|
+
Reference: [api.md][api]. Checking it against the paper: [verify.md][verify], [exact.md][exact].
|
|
135
|
+
|
|
136
|
+
## How it works, in one paragraph
|
|
137
|
+
|
|
138
|
+
Units are the store's own records, packed up to a token budget (512 tokens for record stores, 1,024 for prose) and
|
|
139
|
+
never split mid-record. Parents group about eight neighbouring units. A query is matched three ways: meaning (bge-m3),
|
|
140
|
+
keywords (BM25) and an entity graph over parents. The read budget (`U` units, 10 by default, 40 for prose) is split
|
|
141
|
+
between the three by reserved floors (4/3/3 per ten), so each signal always contributes; candidates are ordered by a
|
|
142
|
+
cross-encoder. Selected units are shown verbatim, one block per parent, in stored order. On numbered logs the newest
|
|
143
|
+
version of a slot replaces older ones.
|
|
144
|
+
|
|
145
|
+
## Two modes
|
|
146
|
+
|
|
147
|
+
- **native** (default): everything above, deterministic for given inputs and versions, with no hash seed and no pinned
|
|
148
|
+
environment. Use this in applications.
|
|
149
|
+
- **exact**: the paper's harness, step for step, under one of nine presets (`muster presets`), for example
|
|
150
|
+
`muster.build(text, "beam.u20")`. Set sets are iterated as the harness iterated them, so it must run under
|
|
151
|
+
`PYTHONHASHSEED=0` with the gate's package versions. Use this to check a paper number.
|
|
152
|
+
|
|
153
|
+
With the same plan, native mode departs from exact mode only where the harness's choice depended on hash or hardware order: canonical
|
|
154
|
+
iteration over entity sets, and a stable sort for exact dense-score ties.
|
|
155
|
+
|
|
156
|
+
Automatically derived non-numbered plans use the balanced method with immediate sibling candidates (`flrs`).
|
|
157
|
+
The frozen paper presets retain each published run's policy, including `flr` where it was recorded; explicit or
|
|
158
|
+
JSON-restored plans are not migrated. See [exact.md][exact] when choosing between automatic planning and replay.
|
|
159
|
+
|
|
160
|
+
## Verification
|
|
161
|
+
|
|
162
|
+
The library is checked against the paper's harness and its published outputs on the paper's data, CPU only, with no
|
|
163
|
+
API call ([exact.md][exact] has every check, its script and its count). In short:
|
|
164
|
+
|
|
165
|
+
| Check | Equal |
|
|
166
|
+
|---|---|
|
|
167
|
+
| Cut of every row of the 24 final legs vs the harness | 296 of 296 rows |
|
|
168
|
+
| Render chain of the MemoryAgentBench board from the published dumps | 5,439 of 5,439 questions |
|
|
169
|
+
| BEAM-100K search and R4 context vs the harness replay | 800 of 800 questions |
|
|
170
|
+
| Other cells replayed, context = the published one | 6,753 of 6,753 questions |
|
|
171
|
+
|
|
172
|
+
## Optional declared record input
|
|
173
|
+
|
|
174
|
+
An experimental [declared record mode](https://github.com/saintmachines/MUSTER/blob/main/docs/library/declared-records.md) connects explicit
|
|
175
|
+
source boundaries and order metadata to the SDK, CLI and an opt-in HTTP endpoint.
|
|
176
|
+
It keeps all versions and does not change the default or paper replay paths.
|
|
177
|
+
|
|
178
|
+
For a producer-declared record array, `record_format="serial"` reversibly reads prefixes such as
|
|
179
|
+
`Step 12: ...`, `#12 ...`, `(12) ...`, `[12] ...`, or `12. ...` using the leading-serial lexer (the integer must end
|
|
180
|
+
within the first 32 code points). Pass `declared_order=SourceOrder(...)` to `muster.build`, or use `"format": "serial"`
|
|
181
|
+
in the declared-record CLI/HTTP envelope. Prefixes and metadata remain in `mem.ordered_records.roundtrip()`; the body
|
|
182
|
+
is what retrieval and the reader receive. This explicit codec does not require the automatic detector's 95%/20-token
|
|
183
|
+
conditions. Gaps, resets and repeated markers do not sort or delete records: declared source order and all versions
|
|
184
|
+
are preserved, with supersession off. The existing `step` and `integer_dot` codecs remain strict and unchanged.
|
|
185
|
+
|
|
186
|
+
For a record array or `Store`, automatic serial detection reads only the start of each record's `text`/`content`.
|
|
187
|
+
An ID, time, or speaker field never supplies a serial. A literal body beginning `user: Step 1: ...` is not rewritten.
|
|
188
|
+
Numbered records keep their serialized metadata in retrieval and reader text, while slots and revision order come
|
|
189
|
+
from the body. Each record remains one unit. Multiline bodies are not split into invented records. Unmarked records
|
|
190
|
+
keep their own occurrence and cannot enable structural replacement. Paper replay and valid, fully marked plain-text
|
|
191
|
+
logs are unchanged. In native lead logs, an unmarked or out-of-bound line keeps its original position and has no
|
|
192
|
+
inferred revision clock, and structural replacement is disabled.
|
|
193
|
+
|
|
194
|
+
For structured records the continuity denominator is the original record pairs, including empty records as missing
|
|
195
|
+
markers, and the length median counts each entire record body, including continuation lines. It does not scan for
|
|
196
|
+
a serial in arbitrary words later in the body. Raw strings retain the existing line-based rule and thresholds.
|
|
197
|
+
An unmarked record has no inferred revision clock. All-marked numbered inputs retain numeric serial display order,
|
|
198
|
+
while an array containing unmarked records is displayed in original array order with structural replacement off.
|
|
199
|
+
|
|
200
|
+
[examples]: https://github.com/saintmachines/MUSTER/tree/main/examples
|
|
201
|
+
[api]: https://github.com/saintmachines/MUSTER/blob/main/docs/library/api.md
|
|
202
|
+
[verify]: https://github.com/saintmachines/MUSTER/blob/main/docs/library/verify.md
|
|
203
|
+
[exact]: https://github.com/saintmachines/MUSTER/blob/main/docs/library/exact.md
|