cogmem 2.7.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.
Files changed (48) hide show
  1. cogmem-2.7.0/LICENSE +201 -0
  2. cogmem-2.7.0/PKG-INFO +291 -0
  3. cogmem-2.7.0/README.md +272 -0
  4. cogmem-2.7.0/cogmem.egg-info/PKG-INFO +291 -0
  5. cogmem-2.7.0/cogmem.egg-info/SOURCES.txt +46 -0
  6. cogmem-2.7.0/cogmem.egg-info/dependency_links.txt +1 -0
  7. cogmem-2.7.0/cogmem.egg-info/entry_points.txt +2 -0
  8. cogmem-2.7.0/cogmem.egg-info/requires.txt +6 -0
  9. cogmem-2.7.0/cogmem.egg-info/top_level.txt +1 -0
  10. cogmem-2.7.0/engine/__init__.py +7 -0
  11. cogmem-2.7.0/engine/acquire.py +226 -0
  12. cogmem-2.7.0/engine/artifacts.py +99 -0
  13. cogmem-2.7.0/engine/cli.py +169 -0
  14. cogmem-2.7.0/engine/common.py +115 -0
  15. cogmem-2.7.0/engine/config.py +67 -0
  16. cogmem-2.7.0/engine/consolidate.py +216 -0
  17. cogmem-2.7.0/engine/daemon.py +158 -0
  18. cogmem-2.7.0/engine/eval.py +217 -0
  19. cogmem-2.7.0/engine/feedback.py +193 -0
  20. cogmem-2.7.0/engine/guard.py +80 -0
  21. cogmem-2.7.0/engine/hooks/cogmem-activate.sh +117 -0
  22. cogmem-2.7.0/engine/hooks/cogmem-capture-pipeline.sh +76 -0
  23. cogmem-2.7.0/engine/hooks/cogmem-capture.sh +57 -0
  24. cogmem-2.7.0/engine/hooks/cogmem-context.sh +23 -0
  25. cogmem-2.7.0/engine/hooks/cogmem-guard.sh +44 -0
  26. cogmem-2.7.0/engine/hooks/cogmem-recall.sh +78 -0
  27. cogmem-2.7.0/engine/index.py +57 -0
  28. cogmem-2.7.0/engine/indexstore.py +121 -0
  29. cogmem-2.7.0/engine/mcp_server.py +456 -0
  30. cogmem-2.7.0/engine/metrics.py +243 -0
  31. cogmem-2.7.0/engine/migrate.py +105 -0
  32. cogmem-2.7.0/engine/narrative.py +134 -0
  33. cogmem-2.7.0/engine/note.py +46 -0
  34. cogmem-2.7.0/engine/projectstate.py +171 -0
  35. cogmem-2.7.0/engine/provenance.py +1224 -0
  36. cogmem-2.7.0/engine/recall.py +72 -0
  37. cogmem-2.7.0/engine/review.py +147 -0
  38. cogmem-2.7.0/engine/selfmodel.py +163 -0
  39. cogmem-2.7.0/engine/softbinding.py +268 -0
  40. cogmem-2.7.0/engine/test_cogmem.py +937 -0
  41. cogmem-2.7.0/engine/test_mcp.py +131 -0
  42. cogmem-2.7.0/engine/test_provenance.py +674 -0
  43. cogmem-2.7.0/engine/test_softbinding.py +184 -0
  44. cogmem-2.7.0/engine/tune.py +71 -0
  45. cogmem-2.7.0/engine/usermodel.py +86 -0
  46. cogmem-2.7.0/engine/wire_hooks.py +53 -0
  47. cogmem-2.7.0/pyproject.toml +54 -0
  48. cogmem-2.7.0/setup.cfg +4 -0
cogmem-2.7.0/LICENSE ADDED
@@ -0,0 +1,201 @@
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 2026 David Condrey
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.
cogmem-2.7.0/PKG-INFO ADDED
@@ -0,0 +1,291 @@
1
+ Metadata-Version: 2.4
2
+ Name: cogmem
3
+ Version: 2.7.0
4
+ Summary: A self-improving, verifiable memory layer for AI coding agents.
5
+ Author: WritersLogic
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/writerslogic/cogmem
8
+ Project-URL: Issues, https://github.com/writerslogic/cogmem/issues
9
+ Keywords: mcp,agent-memory,provenance,did,scitt,verifiable-credentials
10
+ Requires-Python: >=3.12
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: cryptography>=49.0.0
14
+ Requires-Dist: cbor2>=5.9.0
15
+ Provides-Extra: recall
16
+ Requires-Dist: fastembed>=0.8.0; extra == "recall"
17
+ Requires-Dist: numpy>=1.26; extra == "recall"
18
+ Dynamic: license-file
19
+
20
+ <p align="center">
21
+ <img src="https://raw.githubusercontent.com/writerslogic/cogmem/main/assets/logo-spin.gif" width="200" alt="cogmem">
22
+ </p>
23
+
24
+ # cogmem
25
+
26
+ [![CI](https://github.com/writerslogic/cogmem/actions/workflows/ci.yml/badge.svg)](https://github.com/writerslogic/cogmem/actions/workflows/ci.yml)
27
+ [![Python](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://www.python.org)
28
+ [![MCP](https://img.shields.io/badge/MCP-compatible-7c3aed.svg)](https://modelcontextprotocol.io)
29
+ [![cogmem MCP server](https://glama.ai/mcp/servers/writerslogic/cogmem/badges/score.svg)](https://glama.ai/mcp/servers/writerslogic/cogmem)
30
+ [![W3C Verifiable Credentials](https://img.shields.io/badge/W3C-Verifiable%20Credentials-005a9c.svg)](https://www.w3.org/TR/vc-data-model-2.0/)
31
+ [![SCITT](https://img.shields.io/badge/IETF-SCITT--style%20log-005a9c.svg)](https://datatracker.ietf.org/wg/scitt/about/)
32
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
33
+ [![local-first recall](https://img.shields.io/badge/local--first-recall%20runs%20on%20your%20machine-111827.svg)](#privacy)
34
+
35
+ **A self-improving, verifiable memory layer for AI coding agents.**
36
+
37
+ cogmem learns how you work across sessions so your agent gets more accurate and more autonomous over time: it stops repeating mistakes, keeps a live model of each project, and surfaces the right lesson at the right moment. Every memory is cryptographically signed and tamper-evident, so a poisoned or altered memory can be detected and rejected before it ever steers the agent.
38
+
39
+ > Developed by [WritersLogic](https://github.com/writerslogic) — local-first recall; your memory and identity key stay on your machine (see [Privacy](#privacy)).
40
+
41
+ [![cogmem MCP server](https://glama.ai/mcp/servers/writerslogic/cogmem/badges/card.svg)](https://glama.ai/mcp/servers/writerslogic/cogmem)
42
+
43
+ ## Installation
44
+
45
+ ### From PyPI
46
+
47
+ ```bash
48
+ pip install cogmem # CLI + MCP server + verifiable-memory tools
49
+ pip install 'cogmem[recall]' # add local semantic recall (fastembed)
50
+ cogmem init # wire the Claude Code hooks + build the index
51
+ ```
52
+
53
+ `pip install cogmem` gives you the `cogmem` CLI and the MCP server (`cogmem mcp`, or `uvx cogmem mcp` on demand) — the verifiable-memory tools need only the core install. Add the `[recall]` extra for local semantic recall, then run `cogmem init` to wire the full learning loop (the `SessionStart`/`UserPromptSubmit`/`Stop` hooks and the index) into Claude Code. `cogmem init` is idempotent; re-run it any time.
54
+
55
+ ### Clone installer (turnkey, with the warm daemon)
56
+
57
+ The clone installer does everything `pip install` + `cogmem init` does, plus sets up the warm recall daemon (launchd/systemd) as a managed service:
58
+
59
+ ```bash
60
+ git clone https://github.com/writerslogic/cogmem.git
61
+ cd cogmem
62
+ ./install.sh
63
+ ```
64
+
65
+ Or in one line:
66
+
67
+ ```bash
68
+ curl -fsSL https://raw.githubusercontent.com/writerslogic/cogmem/main/install.sh | bash
69
+ ```
70
+
71
+ `install.sh` is idempotent — run it again any time to upgrade in place. It sets up
72
+ the code under `~/.claude/cogmem`, a self-contained virtualenv with dependencies,
73
+ the `cogmem` CLI on your PATH, the Claude Code hooks, and a warm recall daemon
74
+ (a launchd agent on macOS, a `systemd --user` service on Linux). Requires
75
+ **Python 3.12+**; semantic recall runs on a local model (fastembed, no external
76
+ API). Pass `--no-daemon` or `--no-hooks` to skip those steps; set `COGMEM_HOME`
77
+ to install elsewhere — the CLI, engine, and hooks all resolve it at runtime, so
78
+ a non-default install keeps its memory and identity fully self-contained.
79
+
80
+ ## Custom Installation
81
+
82
+ ### Install to a different directory
83
+
84
+ Set `COGMEM_HOME` to place cogmem somewhere other than the default
85
+ `~/.claude/cogmem`:
86
+
87
+ ```bash
88
+ COGMEM_HOME=/opt/cogmem ./install.sh
89
+ ```
90
+
91
+ Or with the one-liner:
92
+
93
+ ```bash
94
+ curl -fsSL https://raw.githubusercontent.com/writerslogic/cogmem/main/install.sh | COGMEM_HOME=/opt/cogmem bash
95
+ ```
96
+
97
+ The installer copies the code, creates the virtualenv, and symlinks the CLI to
98
+ `~/.local/bin/cogmem` (or wherever `COGMEM_BIN` points).
99
+
100
+ ### CLI path
101
+
102
+ Set `COGMEM_BIN` to control where the `cogmem` CLI symlink is placed:
103
+
104
+ ```bash
105
+ COGMEM_BIN=$HOME/.cargo/bin COGMEM_HOME=/opt/cogmem ./install.sh
106
+ ```
107
+
108
+ If `COGMEM_BIN` is not on your PATH, the installer prints a warning. You can
109
+ always invoke cogmem directly from `$COGMEM_HOME/cogmem`.
110
+
111
+ ### How data directories and identity keys are resolved
112
+
113
+ At runtime the CLI and engine read `COGMEM_HOME` from the environment. When it is
114
+ unset they fall back to `~/.claude/cogmem`. All runtime data lives under the
115
+ `vault/` subdirectory:
116
+
117
+ | Path | Purpose |
118
+ |------|---------|
119
+ | `$COGMEM_HOME/vault/identity/agent.key` | Ed25519 private key (agent identity, `did:key`) |
120
+ | `$COGMEM_HOME/vault/credentials/` | W3C Verifiable Credential storage |
121
+ | `$COGMEM_HOME/vault/rules/` | Layer-A (always-load) and Layer-B (recall) rules |
122
+ | `$COGMEM_HOME/vault/provenance/log.jsonl` | Append-only hash-chained transparency log |
123
+ | `$COGMEM_HOME/vault/provenance/statements/` | COSE_Sign1 SCITT signed statements |
124
+ | `$COGMEM_HOME/engine/.venv/` | Python virtualenv with dependencies |
125
+ | `$COGMEM_HOME/hooks/` | Claude Code hook scripts |
126
+
127
+ The identity key is generated on first run (via `cogmem status` or any engine
128
+ operation) and persisted at `$COGMEM_HOME/vault/identity/agent.key`. The
129
+ corresponding `did:key` is derived from the Ed25519 public key. Moving or
130
+ reinstalling cogmem to a new `COGMEM_HOME` creates a fresh identity unless you
131
+ migrate the `vault/` directory.
132
+
133
+ ### MCP client with a non-default install
134
+
135
+ The standard MCP client configuration works regardless of `COGMEM_HOME` because
136
+ the `cogmem` CLI resolves the environment variable at runtime:
137
+
138
+ ```json
139
+ {
140
+ "mcpServers": {
141
+ "cogmem": { "command": "cogmem", "args": ["mcp"] }
142
+ }
143
+ }
144
+ ```
145
+
146
+ If the CLI is not on your PATH, use the full path:
147
+
148
+ ```json
149
+ {
150
+ "mcpServers": {
151
+ "cogmem": { "command": "/opt/cogmem/cogmem", "args": ["mcp"] }
152
+ }
153
+ }
154
+ ```
155
+
156
+ Or prefix with `COGMEM_HOME` in a shell wrapper:
157
+
158
+ ```json
159
+ {
160
+ "mcpServers": {
161
+ "cogmem": { "command": "env", "args": ["COGMEM_HOME=/opt/cogmem", "cogmem", "mcp"] }
162
+ }
163
+ }
164
+ ```
165
+
166
+ ## Quick Start
167
+
168
+ ```bash
169
+ cogmem status # health check, metrics, agent DID
170
+ cogmem doctor # end-to-end learning-loop health (daemon, API key, trust, backlog)
171
+ cogmem recall "..." # surface relevant past lessons for a task
172
+ cogmem note "..." # record a decision or finding mid-task
173
+ cogmem verify # verify every memory's credential + the transparency log
174
+ cogmem receipt <id> # inclusion proof that a memory is committed in the signed log
175
+ cogmem statement <id> # COSE_Sign1 SCITT signed statement (verifiable by HMS too)
176
+ cogmem trust # show the trusted agent identity (warns on a key mismatch)
177
+ cogmem trust --rotate # re-anchor trust after an intentional key change
178
+ cogmem review list # approve always-load rules
179
+ cogmem mcp # run the MCP server (stdio) for any MCP client
180
+ ```
181
+
182
+ ## MCP Integration
183
+
184
+ Run cogmem as an MCP server and connect any MCP-compatible client:
185
+
186
+ ```json
187
+ {
188
+ "mcpServers": {
189
+ "cogmem": { "command": "cogmem", "args": ["mcp"] }
190
+ }
191
+ }
192
+ ```
193
+
194
+ Eight tools are exposed: `recall`, `note`, `status`, `verify`, `receipt`, `tree_head`, `progress`, `review_pending`, plus read-only resources (the live user model and per-project state).
195
+
196
+ ## Claude Code Integration
197
+
198
+ `install.sh` wires cogmem into Claude Code automatically (idempotently merged into
199
+ `~/.claude/settings.json`) — no manual invocation required. Five hooks make the
200
+ memory loop run in the background:
201
+
202
+ | Event | Hook | What it does |
203
+ |---|---|---|
204
+ | `SessionStart` | `cogmem-activate.sh` | injects promoted always-load (Layer-A) rules + the self-check |
205
+ | `UserPromptSubmit` | `cogmem-recall.sh` | semantic Layer-B recall for the current prompt |
206
+ | `PreToolUse(Bash)` | `cogmem-guard.sh` | intercepts known mistakes at the tool-call boundary before they happen |
207
+ | `PostToolUse(Edit\|Write)` | `cogmem-context.sh` | tracks which files the session is actively editing |
208
+ | `Stop` | `cogmem-capture.sh` | captures the session into memory (acquisition + consolidation) |
209
+
210
+ Every hook is strictly fail-open: any error, timeout, or cold daemon injects
211
+ nothing and never blocks your prompt. The scripts live in `~/.claude/cogmem/hooks/`;
212
+ re-run `install.sh` (or `./install.sh --no-daemon`) to refresh the wiring.
213
+
214
+ <details>
215
+ <summary><strong>Why cogmem?</strong> -- learns from outcomes, models failure modes, verifiable memory</summary>
216
+
217
+ Chat-memory systems (Mem0, Letta, Zep) store and retrieve facts. cogmem is built for coding agents and goes further on three axes:
218
+
219
+ **It learns from outcomes.** A feedback loop scores whether a recalled lesson actually helped, refines rules that prove wrong, and retires ones that mislead.
220
+
221
+ **It models its own failure modes.** cogmem tracks where the agent tends to go wrong in your work and intercepts known mistakes at the tool-call boundary — before they happen, not afterward.
222
+
223
+ **Its memory is verifiable.** Each memory is a W3C Verifiable Credential signed by the agent's `did:key`, recorded in a tamper-evident, SCITT-style transparency log. Agent memory is an attack surface; cogmem makes it auditable and poison-resistant.
224
+
225
+ </details>
226
+
227
+ <details>
228
+ <summary><strong>Features</strong> -- two-layer memory, outcome feedback, self-model, project state, cross-project narrative, self-regulation, verifiable credentials</summary>
229
+
230
+ - **Two-layer memory**: always-loaded directives (scope-gated, human-approved) plus a semantic recall tail (local cross-encoder reranking, no data leaves the machine).
231
+ - **Outcome feedback and self-refinement**: memories earn or lose trust based on whether they actually helped; contradicted rules are corrected through a safe pipeline.
232
+ - **Self-model and guard**: a model of the agent's recurring mistakes, compiled into tripwires that intercept them at the `PreToolUse` boundary.
233
+ - **Project-state model**: a living per-project state (goal, claims, open questions, blockers) that gives situational continuity and reasons across time.
234
+ - **Cross-project progress narrative**: momentum, stalls, and dependencies across projects, surfaced as alerts.
235
+ - **Self-regulation**: recall thresholds tuned automatically against an eval harness.
236
+ - **Verifiable Agent Memory**: `did:key` identity, W3C VC-signed memories, COSE_Sign1 SCITT signed statements (byte-compatible with HMS), a hash-chained transparency log with signed Merkle tree head and RFC 6962 inclusion receipts, optional poison-resistance enforcement. See [PROVENANCE.md](./PROVENANCE.md).
237
+
238
+ </details>
239
+
240
+ <details>
241
+ <summary><strong>Verifiable Memory</strong> -- did:key identity, W3C VC, COSE/SCITT, hash-chained log, poison-resistance</summary>
242
+
243
+ cogmem treats every stored memory as a signed artifact:
244
+
245
+ - **`did:key` identity**: each agent gets a persistent Ed25519 identity, exposed as a W3C DID.
246
+ - **W3C Verifiable Credentials**: every memory is signed with `eddsa-jcs-2022` Data Integrity proofs.
247
+ - **COSE_Sign1 / SCITT signed statements**: byte-identical to the envelope format used by holographic-memory and crosstalk — independently verifiable by any of the three implementations.
248
+ - **Hash-chained transparency log**: append-only JSONL with SHA-256 chaining, a signed Merkle tree head, and RFC 6962-style inclusion receipts.
249
+ - **Poison-resistance**: altered or injected memories fail verification and are rejected before influencing the agent.
250
+
251
+ ```bash
252
+ cogmem verify # check all memories and the log head
253
+ cogmem receipt <memory-id> # prove a memory is in the signed log
254
+ ```
255
+
256
+ See [PROVENANCE.md](./PROVENANCE.md) for the full specification.
257
+
258
+ **Verify the C2PA sample yourself:**
259
+
260
+ ```bash
261
+ # examples/c2pa-agent-credential/ is a real signed C2PA manifest
262
+ # whose agent identity validates in c2patool
263
+ ./examples/c2pa-agent-credential/verify.sh
264
+ ```
265
+
266
+ This proves the whole chain: agent identity (`cawg.ica.credential_valid`) bound to real cognition — a signed cogmem memory and a signed crosstalk reasoning audit, each an independently verifiable Ed25519 COSE/SCITT statement.
267
+
268
+ </details>
269
+
270
+ ## Privacy
271
+
272
+ cogmem is local-first by design. Memories, embeddings, and the identity key live on your machine, and **semantic recall is fully local** — the embedding and reranker models (fastembed) run on-device, so querying your memory never leaves the machine.
273
+
274
+ The **learning pipeline is not local**: acquisition, consolidation, the feedback judge, and the project/user-model synthesis send the relevant session transcript to the Anthropic API (`ANTHROPIC_API_KEY`). That is how rules are extracted and scored. If you need fully-offline operation, run with `--no-hooks` (recall still works) until a local-model extraction path lands. In short: **recall is local; learning calls the API.**
275
+
276
+ ## Part of the Agent-Provenance Stack
277
+
278
+ cogmem is one component of the WritersLogic verifiable agent-provenance pipeline — agent identity, memory, reasoning, and signed output, cryptographically bound end to end.
279
+
280
+ | Project | Role |
281
+ |---|---|
282
+ | **cogmem (this repo)** | Agent identity (CAWG credential) + verifiable, tamper-evident memory (COSE/SCITT) |
283
+ | [crosstalk](https://github.com/writerslogic/crosstalk) | Multi-model orchestrator; signs each turn's reasoning/orchestration audit |
284
+ | [holographic-memory](https://github.com/writerslogic/holographic-memory) | Durable holographic memory store; cross-verifies signed statements and agent identity |
285
+ | WritersProof | C2PA producer: binds identity + memory + reasoning to the signed asset |
286
+
287
+ All four share one substrate — COSE_Sign1 / SCITT signed statements (Ed25519) and W3C DID identity — specified in [UNIFIED-PROVENANCE.md](./UNIFIED-PROVENANCE.md).
288
+
289
+ ## License
290
+
291
+ Apache-2.0 — see [LICENSE](./LICENSE).