elephia 0.1.1__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.
elephia-0.1.1/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 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
+ Copyright 2026 Reg Troka and elephia contributors
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.
elephia-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: elephia
3
+ Version: 0.1.1
4
+ Summary: Git for your AI's context — a local-first, deterministic memory engine for Claude, Codex, and Cursor, served over MCP. An elephant never forgets.
5
+ Author-email: Reg Troka <reg.troka@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://elephia.github.io
8
+ Project-URL: Documentation, https://elephia.github.io
9
+ Project-URL: Repository, https://github.com/elephia/elephia
10
+ Project-URL: Issues, https://github.com/elephia/elephia/issues
11
+ Keywords: mcp,memory,context,llm,claude,codex,cursor,agent,elephant
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: pydantic>=2.0.0
24
+ Provides-Extra: tokens
25
+ Requires-Dist: tiktoken>=0.5; extra == "tokens"
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # elephia 🐘
31
+
32
+ <!-- mcp-name: io.github.elephia/elephia -->
33
+
34
+ **git for your AI's context — an elephant never forgets.** A local-first, deterministic memory engine for Claude Desktop, Claude Code, Codex, and Cursor — served over MCP.
35
+
36
+ Every conversation turn is **committed** to an append-only journal. Durable facts (decisions, corrections, preferences) **merge** into a versioned memory wiki. Each new prompt gets a **branch**: a compact, token-budgeted context patch compiled from your whole history — with full provenance, per-item salience scores, and a token meter that shows exactly what you saved.
37
+
38
+ No embeddings API. No cloud. No LLM in the loop. The compiler is mechanical and deterministic: the same history and prompt always produce the same context, and every selection or exclusion has an inspectable reason.
39
+
40
+ ```
41
+ $ elephia branch "What database does Atlas use?"
42
+ Context Merge Patch:
43
+ - recurring_topics: atlas(20), postgresql(7), dashboard(4)
44
+ Selected Context:
45
+ - [wiki:Atlas Memory] wiki; score=0.636; Atlas Memory - correction: use MySQL.
46
+ - [event:demo_00022] event; score=0.623; Recorded Atlas API limits: 100 rps/tenant ...
47
+ Avoid Stale/Superseded:
48
+ - event:demo_00003 superseded_by event:demo_00005
49
+
50
+ -- 299 tokens (budget 300) | full history would be 670 tokens | saved 371 (55%)
51
+ ```
52
+
53
+ ## Install
54
+
55
+ ```bash
56
+ pip install elephia # or: pipx install elephia / uv tool install elephia
57
+ pip install "elephia[tokens]" # + tiktoken for exact token counts (recommended)
58
+ ```
59
+
60
+ > Or from source: `git clone https://github.com/elephia/elephia && pip install -e ./elephia`
61
+
62
+ ## Quick start (60 seconds)
63
+
64
+ ```bash
65
+ elephia init # create a .elephia/ store here (like git init)
66
+ elephia demo # optional: seed sample data
67
+ elephia branch "What database does Atlas use?" # compile a context patch
68
+ elephia branch "What database does Atlas use?" --explain # why each item was selected/excluded
69
+ elephia stats # token meter: patch tokens vs. tokens saved
70
+ ```
71
+
72
+ ### Prefer buttons to commands?
73
+
74
+ ```bash
75
+ elephia ui # opens a private dashboard in your browser
76
+ ```
77
+
78
+ A local point-and-click view of everything: what your AI knows, facts waiting
79
+ for your approval (approve/reject), a "teach it something" box, search with
80
+ one-click "mark outdated", and a live preview of the exact context any
81
+ question would get — with the token savings metered. Binds to 127.0.0.1 only;
82
+ every request requires a per-session token, so nothing on your network (or any
83
+ website you visit) can reach your store.
84
+
85
+ ## Hook it into your AI apps
86
+
87
+ One command per client — it edits the client's config for you (with a `.bak` backup):
88
+
89
+ ```bash
90
+ elephia install claude-code # writes .mcp.json in the current project
91
+ elephia install claude-desktop # edits claude_desktop_config.json
92
+ elephia install codex # adds [mcp_servers.elephia] to ~/.codex/config.toml
93
+ elephia install cursor # edits ~/.cursor/mcp.json
94
+ elephia install print # just show all config snippets
95
+ ```
96
+
97
+ Restart the client. Then ask Claude (or Codex):
98
+
99
+ > "Use prepare_context to load what you know about this project."
100
+ > "Remember that we deploy on Fridays."
101
+ > "Show me the merge log — what have you saved about me?"
102
+ > "Why didn't you remember X? Explain the selection."
103
+
104
+ ### What the model sees (MCP tools)
105
+
106
+ | Tool | What it does |
107
+ |---|---|
108
+ | `prepare_context` | Compile a token-budgeted context patch relevant to the prompt, with token accounting |
109
+ | `commit_turn` | Journal a finished turn; durable phrasing auto-merges into the wiki |
110
+ | `remember` / `mark_stale` | Explicitly save a fact / retire an outdated one |
111
+ | `search_context` | BM25 search over all events + wiki pages |
112
+ | `context_log` / `show_context` | Recent events; any record in full by ref |
113
+ | `full_context` | Page through the complete raw history (token counts included) |
114
+ | `explain_selection` | Per-item salience scores + exclusion reasons for a prompt |
115
+ | `merge_log` / `resolve_pending` | Merge history; approve/reject pending merges |
116
+ | `context_stats` | Token meter: compilations, tokens served, tokens saved |
117
+
118
+ ## The git mental model
119
+
120
+ | git | elephia |
121
+ |---|---|
122
+ | repository | `.elephia/` store (per project, or `~/.elephia/store` global) |
123
+ | commit | journaled conversation turn (`commit_turn`, append-only `events.jsonl`) |
124
+ | branch | compiled context patch for the current prompt (`elephia branch`) |
125
+ | merge | durable fact saved to the versioned wiki (`merge_log`, `mutations.jsonl`) |
126
+ | staging area | pending-merge queue (`elephia pending list / approve / reject`) |
127
+ | log / show | `elephia log`, `elephia show event:<id> | wiki:<title> | mut:<id>` |
128
+ | blame | provenance: every wiki claim links to the source events that produced it |
129
+
130
+ Store resolution is git-style too: `--store` flag → `CONTEXTGIT_DIR` env var → nearest `.elephia/` walking up from the working directory → global `~/.elephia/store`.
131
+
132
+ ## Why deterministic?
133
+
134
+ Memory systems that summarize with an LLM are unauditable: you can't know why something was remembered, forgotten, or silently rewritten. elephia's compiler is a mechanical scoring function (frequency, recency, query relevance via BM25, correction priority, source confidence, open-loop bonus, token cost, staleness penalty). That means:
135
+
136
+ - **Reproducible** — same store + same prompt = same context, byte for byte.
137
+ - **Explainable** — `--explain` shows each item's score components and exclusion reasons.
138
+ - **Correction-safe** — "use MySQL instead of PostgreSQL" supersedes the old fact; stale items are excluded *and* listed under "Avoid Stale/Superseded" so the model doesn't relearn them.
139
+ - **Auditable** — every memory mutation is in an append-only log with before/after state hashes.
140
+
141
+ ## Token tracking
142
+
143
+ Every compilation appends a row to `usage.jsonl`: patch tokens, what full history would have cost, tokens saved. Counting uses tiktoken when installed (`o200k_base`), with an honest `fallback_estimate` label otherwise.
144
+
145
+ ```bash
146
+ elephia stats
147
+ # compilations patch tokens saved tokens savings
148
+ # all time 14 4186 21340 63.1%
149
+ ```
150
+
151
+ ## Storage format (yours, forever)
152
+
153
+ Plain JSONL in `.elephia/` — no database, no lock-in:
154
+
155
+ ```
156
+ events.jsonl append-only conversation journal
157
+ wiki_versions.jsonl every version of every memory page
158
+ mutations.jsonl append-only merge log (save / promote / mark_stale / reject)
159
+ audit.jsonl decision audit with state hashes
160
+ pending.json merge candidates awaiting review
161
+ usage.jsonl token meter ledger
162
+ ```
163
+
164
+ `elephia export` dumps a single JSON snapshot.
165
+
166
+ ## Development
167
+
168
+ ```bash
169
+ pip install -e ".[dev,tokens]"
170
+ pytest
171
+ ```
172
+
173
+ The engine (deterministic compiler, BM25 retrieval, versioned store) is benchmarked against eager/full-history baselines on contamination, staleness, and recall metrics in a separate research harness.
174
+
175
+ ## Known limitations
176
+
177
+ elephia is young (v0.1.x, beta). Today:
178
+
179
+ - **One writer per store at a time.** There's no file lock yet, so two clients writing the *same* store at the same moment can collide. Use per-project stores (the default) and avoid hammering one store from several apps at once.
180
+ - **Best for small/medium stores.** Context compilation stays interactive up to roughly 500 turns per store; very large stores get slow. Keep stores per-project and archive occasionally.
181
+ - **Keep a backup.** `elephia export` writes a JSON snapshot. elephia now skips a torn line rather than failing the whole store, but a periodic export is cheap insurance against a crash mid-write.
182
+ - **Retrieval is lexical (BM25), not semantic.** It finds notes by shared words, not meaning — treat the served context as a recall aid the model should sanity-check, not gospel.
183
+
184
+ These are tracked on the roadmap.
185
+
186
+ ## License
187
+
188
+ Apache-2.0
@@ -0,0 +1,159 @@
1
+ # elephia 🐘
2
+
3
+ <!-- mcp-name: io.github.elephia/elephia -->
4
+
5
+ **git for your AI's context — an elephant never forgets.** A local-first, deterministic memory engine for Claude Desktop, Claude Code, Codex, and Cursor — served over MCP.
6
+
7
+ Every conversation turn is **committed** to an append-only journal. Durable facts (decisions, corrections, preferences) **merge** into a versioned memory wiki. Each new prompt gets a **branch**: a compact, token-budgeted context patch compiled from your whole history — with full provenance, per-item salience scores, and a token meter that shows exactly what you saved.
8
+
9
+ No embeddings API. No cloud. No LLM in the loop. The compiler is mechanical and deterministic: the same history and prompt always produce the same context, and every selection or exclusion has an inspectable reason.
10
+
11
+ ```
12
+ $ elephia branch "What database does Atlas use?"
13
+ Context Merge Patch:
14
+ - recurring_topics: atlas(20), postgresql(7), dashboard(4)
15
+ Selected Context:
16
+ - [wiki:Atlas Memory] wiki; score=0.636; Atlas Memory - correction: use MySQL.
17
+ - [event:demo_00022] event; score=0.623; Recorded Atlas API limits: 100 rps/tenant ...
18
+ Avoid Stale/Superseded:
19
+ - event:demo_00003 superseded_by event:demo_00005
20
+
21
+ -- 299 tokens (budget 300) | full history would be 670 tokens | saved 371 (55%)
22
+ ```
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ pip install elephia # or: pipx install elephia / uv tool install elephia
28
+ pip install "elephia[tokens]" # + tiktoken for exact token counts (recommended)
29
+ ```
30
+
31
+ > Or from source: `git clone https://github.com/elephia/elephia && pip install -e ./elephia`
32
+
33
+ ## Quick start (60 seconds)
34
+
35
+ ```bash
36
+ elephia init # create a .elephia/ store here (like git init)
37
+ elephia demo # optional: seed sample data
38
+ elephia branch "What database does Atlas use?" # compile a context patch
39
+ elephia branch "What database does Atlas use?" --explain # why each item was selected/excluded
40
+ elephia stats # token meter: patch tokens vs. tokens saved
41
+ ```
42
+
43
+ ### Prefer buttons to commands?
44
+
45
+ ```bash
46
+ elephia ui # opens a private dashboard in your browser
47
+ ```
48
+
49
+ A local point-and-click view of everything: what your AI knows, facts waiting
50
+ for your approval (approve/reject), a "teach it something" box, search with
51
+ one-click "mark outdated", and a live preview of the exact context any
52
+ question would get — with the token savings metered. Binds to 127.0.0.1 only;
53
+ every request requires a per-session token, so nothing on your network (or any
54
+ website you visit) can reach your store.
55
+
56
+ ## Hook it into your AI apps
57
+
58
+ One command per client — it edits the client's config for you (with a `.bak` backup):
59
+
60
+ ```bash
61
+ elephia install claude-code # writes .mcp.json in the current project
62
+ elephia install claude-desktop # edits claude_desktop_config.json
63
+ elephia install codex # adds [mcp_servers.elephia] to ~/.codex/config.toml
64
+ elephia install cursor # edits ~/.cursor/mcp.json
65
+ elephia install print # just show all config snippets
66
+ ```
67
+
68
+ Restart the client. Then ask Claude (or Codex):
69
+
70
+ > "Use prepare_context to load what you know about this project."
71
+ > "Remember that we deploy on Fridays."
72
+ > "Show me the merge log — what have you saved about me?"
73
+ > "Why didn't you remember X? Explain the selection."
74
+
75
+ ### What the model sees (MCP tools)
76
+
77
+ | Tool | What it does |
78
+ |---|---|
79
+ | `prepare_context` | Compile a token-budgeted context patch relevant to the prompt, with token accounting |
80
+ | `commit_turn` | Journal a finished turn; durable phrasing auto-merges into the wiki |
81
+ | `remember` / `mark_stale` | Explicitly save a fact / retire an outdated one |
82
+ | `search_context` | BM25 search over all events + wiki pages |
83
+ | `context_log` / `show_context` | Recent events; any record in full by ref |
84
+ | `full_context` | Page through the complete raw history (token counts included) |
85
+ | `explain_selection` | Per-item salience scores + exclusion reasons for a prompt |
86
+ | `merge_log` / `resolve_pending` | Merge history; approve/reject pending merges |
87
+ | `context_stats` | Token meter: compilations, tokens served, tokens saved |
88
+
89
+ ## The git mental model
90
+
91
+ | git | elephia |
92
+ |---|---|
93
+ | repository | `.elephia/` store (per project, or `~/.elephia/store` global) |
94
+ | commit | journaled conversation turn (`commit_turn`, append-only `events.jsonl`) |
95
+ | branch | compiled context patch for the current prompt (`elephia branch`) |
96
+ | merge | durable fact saved to the versioned wiki (`merge_log`, `mutations.jsonl`) |
97
+ | staging area | pending-merge queue (`elephia pending list / approve / reject`) |
98
+ | log / show | `elephia log`, `elephia show event:<id> | wiki:<title> | mut:<id>` |
99
+ | blame | provenance: every wiki claim links to the source events that produced it |
100
+
101
+ Store resolution is git-style too: `--store` flag → `CONTEXTGIT_DIR` env var → nearest `.elephia/` walking up from the working directory → global `~/.elephia/store`.
102
+
103
+ ## Why deterministic?
104
+
105
+ Memory systems that summarize with an LLM are unauditable: you can't know why something was remembered, forgotten, or silently rewritten. elephia's compiler is a mechanical scoring function (frequency, recency, query relevance via BM25, correction priority, source confidence, open-loop bonus, token cost, staleness penalty). That means:
106
+
107
+ - **Reproducible** — same store + same prompt = same context, byte for byte.
108
+ - **Explainable** — `--explain` shows each item's score components and exclusion reasons.
109
+ - **Correction-safe** — "use MySQL instead of PostgreSQL" supersedes the old fact; stale items are excluded *and* listed under "Avoid Stale/Superseded" so the model doesn't relearn them.
110
+ - **Auditable** — every memory mutation is in an append-only log with before/after state hashes.
111
+
112
+ ## Token tracking
113
+
114
+ Every compilation appends a row to `usage.jsonl`: patch tokens, what full history would have cost, tokens saved. Counting uses tiktoken when installed (`o200k_base`), with an honest `fallback_estimate` label otherwise.
115
+
116
+ ```bash
117
+ elephia stats
118
+ # compilations patch tokens saved tokens savings
119
+ # all time 14 4186 21340 63.1%
120
+ ```
121
+
122
+ ## Storage format (yours, forever)
123
+
124
+ Plain JSONL in `.elephia/` — no database, no lock-in:
125
+
126
+ ```
127
+ events.jsonl append-only conversation journal
128
+ wiki_versions.jsonl every version of every memory page
129
+ mutations.jsonl append-only merge log (save / promote / mark_stale / reject)
130
+ audit.jsonl decision audit with state hashes
131
+ pending.json merge candidates awaiting review
132
+ usage.jsonl token meter ledger
133
+ ```
134
+
135
+ `elephia export` dumps a single JSON snapshot.
136
+
137
+ ## Development
138
+
139
+ ```bash
140
+ pip install -e ".[dev,tokens]"
141
+ pytest
142
+ ```
143
+
144
+ The engine (deterministic compiler, BM25 retrieval, versioned store) is benchmarked against eager/full-history baselines on contamination, staleness, and recall metrics in a separate research harness.
145
+
146
+ ## Known limitations
147
+
148
+ elephia is young (v0.1.x, beta). Today:
149
+
150
+ - **One writer per store at a time.** There's no file lock yet, so two clients writing the *same* store at the same moment can collide. Use per-project stores (the default) and avoid hammering one store from several apps at once.
151
+ - **Best for small/medium stores.** Context compilation stays interactive up to roughly 500 turns per store; very large stores get slow. Keep stores per-project and archive occasionally.
152
+ - **Keep a backup.** `elephia export` writes a JSON snapshot. elephia now skips a torn line rather than failing the whole store, but a periodic export is cheap insurance against a crash mid-write.
153
+ - **Retrieval is lexical (BM25), not semantic.** It finds notes by shared words, not meaning — treat the served context as a recall aid the model should sanity-check, not gospel.
154
+
155
+ These are tracked on the roadmap.
156
+
157
+ ## License
158
+
159
+ Apache-2.0
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "elephia"
7
+ version = "0.1.1"
8
+ description = "Git for your AI's context — a local-first, deterministic memory engine for Claude, Codex, and Cursor, served over MCP. An elephant never forgets."
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ authors = [{ name = "Reg Troka", email = "reg.troka@gmail.com" }]
12
+ requires-python = ">=3.10"
13
+ keywords = ["mcp", "memory", "context", "llm", "claude", "codex", "cursor", "agent", "elephant"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Software Development :: Libraries",
23
+ ]
24
+ dependencies = [
25
+ "pydantic>=2.0.0",
26
+ ]
27
+
28
+ [project.optional-dependencies]
29
+ tokens = ["tiktoken>=0.5"]
30
+ dev = ["pytest>=7.0"]
31
+
32
+ [project.urls]
33
+ Homepage = "https://elephia.github.io"
34
+ Documentation = "https://elephia.github.io"
35
+ Repository = "https://github.com/elephia/elephia"
36
+ Issues = "https://github.com/elephia/elephia/issues"
37
+
38
+ [project.scripts]
39
+ elephia = "elephia.cli:main"
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+ """elephia - git for your AI's context.
2
+
3
+ A local-first, deterministic memory engine exposed over MCP (Model Context
4
+ Protocol) and a git-style CLI. Every conversation turn is committed to an
5
+ append-only journal; durable facts merge into a versioned wiki; each prompt
6
+ gets a token-budgeted, salience-ranked context "branch" compiled from history.
7
+ """
8
+
9
+ __version__ = "0.1.1"
10
+
11
+ from elephia.engine import Elephia, resolve_store_dir # noqa: F401
@@ -0,0 +1,4 @@
1
+ from elephia.cli import main
2
+
3
+ if __name__ == "__main__":
4
+ raise SystemExit(main())