Skip to content

Commit c5b583f

Browse files
committed
Task Authority (Release v0.7.0)
1 parent 1d39484 commit c5b583f

File tree

17 files changed

+240
-59
lines changed

17 files changed

+240
-59
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ Never guess. Never proceed optimistically.
220220

221221
- [ ] Top-level task
222222
- [ ] Atomic subtask
223+
- [ ] Task definition and details
223224
```
224225

225226
Rules:

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ Never guess. Never proceed optimistically.
220220

221221
- [ ] Top-level task
222222
- [ ] Atomic subtask
223+
- [ ] Task definition and details
223224
```
224225

225226
Rules:

CRUSH.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Mutation is explicit.
3737
* `memory_query`
3838
* `memory_recent`
3939

40-
Required before any mutation.
40+
Available in ALL modes (implementing "Observation is free").
41+
Required before any mutation in GUARDED/STRICT modes.
4142

4243
### Intent Declaration
4344

@@ -109,7 +110,9 @@ Mode MUST be declared via `memory_set_mode` before mutation.
109110

110111
### R1 — Recall Before Mutation
111112

112-
Before any mutation, you MUST:
113+
Memory recall tools (`memory_query`, `memory_recent`) are available in ALL modes (implementing "Observation is free").
114+
115+
Before any mutation in GUARDED/STRICT modes, you MUST:
113116

114117
* call `memory_query` or `memory_recent`
115118
* acknowledge the result (even if empty)
@@ -169,7 +172,7 @@ The agent may NOT:
169172

170173
Before any mutation, ALL of the following MUST be true, in order:
171174

172-
1. R1 satisfied (memory recall)
175+
1. R1 satisfied (memory recall in GUARDED/STRICT modes)
173176
2. Intent declared via `memory_set_mode`
174177
3. R2 satisfied (task externalised if required)
175178
4. R3 satisfied (task authority confirmed)
@@ -217,6 +220,7 @@ Never guess. Never proceed optimistically.
217220

218221
- [ ] Top-level task
219222
- [ ] Atomic subtask
223+
- [ ] Task definition and details
220224
```
221225

222226
Rules:
@@ -255,7 +259,7 @@ If a required tool fails:
255259

256260
Confirm explicitly:
257261

258-
* recall completed (R1)
262+
* recall completed in GUARDED/STRICT modes (R1)
259263
* mode declared (R4)
260264
* task authority resolved (R2, R3)
261265
* memory writes completed or not required (R5)

GEMINI.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ Never guess. Never proceed optimistically.
220220

221221
- [ ] Top-level task
222222
- [ ] Atomic subtask
223+
- [ ] Task definition and details
223224
```
224225

225226
Rules:

QWEN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ Never guess. Never proceed optimistically.
220220

221221
- [ ] Top-level task
222222
- [ ] Atomic subtask
223+
- [ ] Task definition and details
223224
```
224225

225226
Rules:

README.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,12 @@ As the project grew, we realized that memory alone wasn't enough. Reliability re
103103
Get up and running in seconds.
104104

105105
### 1. Initialize
106-
Go to your project root and initialize the memory database:
106+
Go to your project root and bootstrap the memory system (this also downloads `docs/agents/AGENT_CONTRACT*.md` so your proxy/MCP layers have the exact system prompt they inject):
107107
```bash
108108
cd /path/to/your/project
109-
tinymem health
109+
tinymem init
110110
```
111+
If you just want to verify the installation afterward, run `tinymem health`.
111112

112113
### 2. Run
113114
Start the server (choose one mode):
@@ -197,8 +198,8 @@ The tinyMem CLI is your primary way to interact with the system from your termin
197198
| `run` | **Command Wrapper**| To run a script or tool (like `make` or `npm test`) while "reminding" it of project context. | `tinymem run make build` |
198199
| `proxy` / `mcp` | **Server Modes** | To start the "brain" that connects tinyMem to your IDE or AI client. | `tinymem mcp` |
199200
| `doctor` | **Diagnostics** | To fix the system if it stops working or has configuration issues. | `tinymem doctor` |
200-
| `init` | **Project Bootstrap** | Creates `.tinyMem`, writes the config, and installs the correct agent contracts for your model size. | `tinymem init` |
201-
| `update` | **Refresh** | Re-runs migrations and downloads whichever agent contract matches your configuration. | `tinymem update` |
201+
| `init` | **Project Bootstrap** | Creates `.tinyMem`, writes the config, and downloads the AGENT_CONTRACT/AGENT_CONTRACT_SMALL files into `docs/agents` so proxy and MCP modes can inject them without touching your README. | `tinymem init` |
202+
| `update` | **Refresh** | Re-runs migrations and refreshes the configured agent contract files under `docs/agents` (large or small) to keep proxy/MCP injections in sync. | `tinymem update` |
202203

203204
### Writing Memories
204205
Think of writing memories as "tagging" reality for the AI.
@@ -266,6 +267,8 @@ export OPENAI_API_BASE_URL=http://localhost:8080/v1
266267
# Your existing scripts now use tinyMem automatically
267268
```
268269

270+
`tinymem init` seeds `docs/agents/AGENT_CONTRACT.md` and `AGENT_CONTRACT_SMALL.md` and the proxy loads the configured file at startup, injecting it as the first system message unless the client already shipped the `**Start of tinyMem Protocol**` marker. This means your SDKs never need to resend the contract; tinyMem enforces it once per request.
271+
269272
While proxying, tinyMem now reports recall activity back to the client so that downstream UIs or agents can show “memory checked” indicators:
270273
* **Streaming responses** append an SSE event of type `tinymem.memory_status` once the upstream LLM finishes. The payload includes `recall_count`, `recall_status` (`none`/`injected`/`failed`), and a timestamp.
271274
* **Non-streaming responses** carry the same data via new headers: `X-TinyMem-Recall-Status` and `X-TinyMem-Recall-Count`.
@@ -287,19 +290,23 @@ Compatible with Claude Desktop, Cursor, and other MCP clients.
287290
```
288291

289292
#### Available MCP Tools:
290-
When tinyMem is running in MCP mode, your AI agent (like Claude or Gemini) gains these "superpowers":
291-
292-
* **`memory_query`**: **Search the past.** The AI uses this to find facts, decisions, or notes related to its current task.
293-
* **`memory_recent`**: **Get up to speed.** The AI uses this when it first starts to see what has happened recently in the project.
294-
* **`memory_write`**: **Learn something new.** The AI uses this to save a new fact or decision it just discovered or made. *Facts require "Evidence" (like checking if a file exists).*
295-
* **`memory_ralph`**: **Self-Repair.** This is the "Nuclear Option." The AI uses this to try and fix a bug autonomously by running tests, reading errors, and retrying until it works.
296-
* **`memory_stats` & `memory_health`**: **System Check.** The AI uses these to check if its memory is working correctly or how much it has learned.
297-
* **`memory_doctor`**: **Self-Diagnosis.** If the AI feels "confused" or senses memory issues, it can run this to identify problems.
293+
When tinyMem is running in MCP mode, your AI agent gains a fixed set of tools for recall, enforcement, and diagnostics:
294+
295+
* **`memory_query`**: Search project memories with lexical recall (PASSIVE). Always run this before writing anything in GUARDED/STRICT modes.
296+
* **`memory_recent`**: Fetch the latest memories to understand the current context before acting.
297+
* **`memory_run_metadata`**: Inspect the enforcement run metadata (execution mode, events, proven counts) to prove the protocol was followed.
298+
* **`memory_claim_success`**: Report whether a claimed success was observed and enforced; adversarial claims without enforcement get flagged.
299+
* **`memory_set_mode`**: Declare PASSIVE, GUARDED, or STRICT before mutations; this is the intent gatekeeper for all memory writes.
300+
* **`memory_check_task_authority`**: Ask tinyMem to read `tinyTasks.md` and confirm which task (if any) has authority so the agent knows what work is authorized.
301+
* **`memory_write`**: Create or update memories with evidence (facts require verified evidence, and recall must happen first in GUARDED/STRICT modes).
302+
* **`memory_stats`** & **`memory_health`**: Surface memory counts, evidence coverage, and database health for monitoring.
303+
* **`memory_doctor`**: Run a self-diagnostic that checks configuration, database connectivity, and enforcement hooks.
304+
* **`memory_eval_stats`**: Retrieve evaluation metrics that measure how well memories, tasks, and enforcement performed during a session.
298305

299306
### AI Agent Directives
300307
**CRITICAL**: If you are building an AI agent, you MUST include the appropriate directive in its system prompt to ensure it uses tinyMem correctly.
301308

302-
**Quick Setup:** Run `tinymem init` once to bootstrap `.tinyMem`, create config, and install the correct agent contract for your model size. Use `tinymem update` later to rerun migrations and refresh the contract (it will download the small or large version that your configuration points to).
309+
**Quick Setup:** Run `tinymem init` once to bootstrap `.tinyMem`, create config, and download the AGENT_CONTRACT/AGENT_CONTRACT_SMALL files that the proxy and MCP layers inject. `tinymem update` reruns migrations and refreshes the same contract files (large or small) without mutating your README.
303310

304311
* **Claude**: [`docs/agents/CLAUDE.md`](docs/agents/CLAUDE.md)
305312
* **Gemini**: [`docs/agents/GEMINI.md`](docs/agents/GEMINI.md)

docs/agents/AGENTS.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Mutation is explicit.
3737
* `memory_query`
3838
* `memory_recent`
3939

40-
Required before any mutation.
40+
Available in ALL modes (implementing "Observation is free").
41+
Required before any mutation in GUARDED/STRICT modes.
4142

4243
### Intent Declaration
4344

@@ -109,7 +110,9 @@ Mode MUST be declared via `memory_set_mode` before mutation.
109110

110111
### R1 — Recall Before Mutation
111112

112-
Before any mutation, you MUST:
113+
Memory recall tools (`memory_query`, `memory_recent`) are available in ALL modes (implementing "Observation is free").
114+
115+
Before any mutation in GUARDED/STRICT modes, you MUST:
113116

114117
* call `memory_query` or `memory_recent`
115118
* acknowledge the result (even if empty)
@@ -169,7 +172,7 @@ The agent may NOT:
169172

170173
Before any mutation, ALL of the following MUST be true, in order:
171174

172-
1. R1 satisfied (memory recall)
175+
1. R1 satisfied (memory recall in GUARDED/STRICT modes)
173176
2. Intent declared via `memory_set_mode`
174177
3. R2 satisfied (task externalised if required)
175178
4. R3 satisfied (task authority confirmed)
@@ -217,6 +220,7 @@ Never guess. Never proceed optimistically.
217220

218221
- [ ] Top-level task
219222
- [ ] Atomic subtask
223+
- [ ] Task definition and details
220224
```
221225

222226
Rules:
@@ -255,7 +259,7 @@ If a required tool fails:
255259

256260
Confirm explicitly:
257261

258-
* recall completed (R1)
262+
* recall completed in GUARDED/STRICT modes (R1)
259263
* mode declared (R4)
260264
* task authority resolved (R2, R3)
261265
* memory writes completed or not required (R5)

docs/agents/AGENT_CONTRACT.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Mutation is explicit.
3737
* `memory_query`
3838
* `memory_recent`
3939

40-
Required before any mutation.
40+
Available in ALL modes (implementing "Observation is free").
41+
Required before any mutation in GUARDED/STRICT modes.
4142

4243
### Intent Declaration
4344

@@ -109,7 +110,9 @@ Mode MUST be declared via `memory_set_mode` before mutation.
109110

110111
### R1 — Recall Before Mutation
111112

112-
Before any mutation, you MUST:
113+
Memory recall tools (`memory_query`, `memory_recent`) are available in ALL modes (implementing "Observation is free").
114+
115+
Before any mutation in GUARDED/STRICT modes, you MUST:
113116

114117
* call `memory_query` or `memory_recent`
115118
* acknowledge the result (even if empty)
@@ -169,7 +172,7 @@ The agent may NOT:
169172

170173
Before any mutation, ALL of the following MUST be true, in order:
171174

172-
1. R1 satisfied (memory recall)
175+
1. R1 satisfied (memory recall in GUARDED/STRICT modes)
173176
2. Intent declared via `memory_set_mode`
174177
3. R2 satisfied (task externalised if required)
175178
4. R3 satisfied (task authority confirmed)
@@ -217,6 +220,7 @@ Never guess. Never proceed optimistically.
217220

218221
- [ ] Top-level task
219222
- [ ] Atomic subtask
223+
- [ ] Task definition and details
220224
```
221225

222226
Rules:
@@ -255,7 +259,7 @@ If a required tool fails:
255259

256260
Confirm explicitly:
257261

258-
* recall completed (R1)
262+
* recall completed in GUARDED/STRICT modes (R1)
259263
* mode declared (R4)
260264
* task authority resolved (R2, R3)
261265
* memory writes completed or not required (R5)

docs/agents/AGENT_CONTRACT_SMALL.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,15 @@ State the block.
172172
> These tasks were proposed by the agent.
173173
> No work is authorised until a human reviews and confirms them.
174174
>
175-
## Tasks
176-
<!-- No tasks defined yet -->
175+
### Active Task Structure
177176
```
177+
```md
178+
# Tasks – <Goal>
178179

180+
- [ ] Top-level task
181+
- [ ] Atomic subtask
182+
- [ ] Task definition and details
183+
```
179184
Rules:
180185

181186
* Two levels only

docs/agents/CLAUDE.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Mutation is explicit.
3737
* `memory_query`
3838
* `memory_recent`
3939

40-
Required before any mutation.
40+
Available in ALL modes (implementing "Observation is free").
41+
Required before any mutation in GUARDED/STRICT modes.
4142

4243
### Intent Declaration
4344

@@ -109,7 +110,9 @@ Mode MUST be declared via `memory_set_mode` before mutation.
109110

110111
### R1 — Recall Before Mutation
111112

112-
Before any mutation, you MUST:
113+
Memory recall tools (`memory_query`, `memory_recent`) are available in ALL modes (implementing "Observation is free").
114+
115+
Before any mutation in GUARDED/STRICT modes, you MUST:
113116

114117
* call `memory_query` or `memory_recent`
115118
* acknowledge the result (even if empty)
@@ -169,7 +172,7 @@ The agent may NOT:
169172

170173
Before any mutation, ALL of the following MUST be true, in order:
171174

172-
1. R1 satisfied (memory recall)
175+
1. R1 satisfied (memory recall in GUARDED/STRICT modes)
173176
2. Intent declared via `memory_set_mode`
174177
3. R2 satisfied (task externalised if required)
175178
4. R3 satisfied (task authority confirmed)
@@ -217,6 +220,7 @@ Never guess. Never proceed optimistically.
217220

218221
- [ ] Top-level task
219222
- [ ] Atomic subtask
223+
- [ ] Task definition and details
220224
```
221225

222226
Rules:
@@ -255,7 +259,7 @@ If a required tool fails:
255259

256260
Confirm explicitly:
257261

258-
* recall completed (R1)
262+
* recall completed in GUARDED/STRICT modes (R1)
259263
* mode declared (R4)
260264
* task authority resolved (R2, R3)
261265
* memory writes completed or not required (R5)

0 commit comments

Comments
 (0)